The YOLO Challenge

yoloThe YOLO challenge consists of creating an acronym generator: a program that prompts the user to enter an expression or a sentence (e.g. “You only live once!”) and in return gives the acronym matching the user input (e.g. “YOLO”)

Learning Objectives


In this challenge you will further improve your string manipulation techniques and your use of lists in Python. You will investigate how to split a string into a list and how to iterate through each item of a list.

Tips

  • First you may investigate the split() method that can be used on any string:
    myStr = "Millie,Luke,Will,Esther"
    myList = myStr.split(" ")
    #This would return a list as follows: ["Millie","Luke","Will","Esther"]
  • You may also look at the upper() and lower() method that can be used to convert a string to UPPERCASE or lowercase.
    For instance:
    myStr.upper() would convert the myStr string to uppercase.
  • To access specific characters of a string using their position you can use the following notation:myStr[0] (This would return the first character of a string called myStr).
  • Finally to iterate through all the values in a list, you may need to use a for loop:
    myList = ["Millie","Luke","Will","Esther"]
    for pupil in myList:
       print(pupil)

Your Turn


Use all of the above tips to complete the YOLO challenge:

Challenge #2


You may want to fine tune your code so that words like “the” or “a” are being ignored.

Did you like this challenge?

Click on a star to rate it!

Average rating 2.8 / 5. Vote count: 4

No votes so far! Be the first to rate this post.

As you found this challenge interesting...

Follow us on social media!

Tagged with: ,