I have a string:
'Piethon is good' How can I get the first letter of each word in the string? For example, the first letter of each word in the above string would be:
P i g 82 Answers
[ s[0] for s in 'Piethon is good'.split() ] How about you just slice the string when printing (or assign a new variable) and remove start = word[0:][0]:
trans = input("enter a sentence ") trans = trans.lower() t_list = trans.split() for word in t_list: print(word[0]) This works because you get a list containing all the values of the string (by default split() splits white-space), next you initerate through that list (this returns a single character) and then get the value of the first character of the string.
You could also use trans = input("enter a sentence ").lower().split() rather than redefine trans into a new variable each time.