Jan-05-2021, 12:00 PM
I am trying to take out the first letter of every word in a list. It is not working. I believe the fault to be on line 9 but i can't figure out why.
def initialise(userText):
lst = []
firstLetters = []
for i in userText:
lst.append(i)
firstLetters.append(lst[0])
for x in lst:
if x == " ":
position = lst.index(x) + 1
firstLetters.append(lst[position])
userText = ''.join(firstLetters)
return userText
text = input("Enter text: ")
print(initialise(text))
