I am trying to use a for
loop to find every word in a string that contains exactly one letter e.
My guess is that I need to use a for
loop to first separate each word in the string into its own list (for example, this is a string
into ['this']
, ['is']
, ['a']
, ['string']
)
Then, I can use another For Loop to check each word/list.
My string is stored in the variable joke.
I'm having trouble structuring my For Loop to make each word into its own list. Any suggestions?
j2 = []
for s in joke:
if s[0] in j2:
j2[s[0]] = joke.split()
else:
j2[s[0]] = s[0]
print(j2)