The 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”)
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.
- First you may investigate the split() method that can be used on any string:
Python123myStr = "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.
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 (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:
Python123myList = ["Millie","Luke","Will","Esther"]for pupil in myList:print(pupil)
Use all of the above tips to complete the YOLO challenge:
You may want to fine tune your code so that words like “the” or “a” are being ignored.