Skip to content

Instantly share code, notes, and snippets.

@MustafaCoder2022
Created June 12, 2022 08:49
Show Gist options
  • Save MustafaCoder2022/e481202efe774127e7b298f37c942266 to your computer and use it in GitHub Desktop.
Save MustafaCoder2022/e481202efe774127e7b298f37c942266 to your computer and use it in GitHub Desktop.
For each string in wrds, add ‘ed’ to the end of the word (to make the word past tense). Save these past tense words to a list called past_wrds.
wrds = ["end", 'work', "play", "start", "walk", "look", "open", "rain", "learn", "clean"]
past_wrds =[]
for i in wrds:
i +='ed'
if i not in past_wrds:
past_wrds.append(i)
print(past_wrds)
@MustafaCoder2022
Copy link
Author

Challenge For each word in words, add ‘d’ to the end of the word if the word ends in “e” to make it past tense. Otherwise, add ‘ed’ to make it past tense. Save these past tense words to a list called past_tense.

words = ["adopt", "bake", "beam", "confide", "grill", "plant", "time", "wave", "wish"]
past_tense=[]
for i in words:
if i[-1] != 'e':
i +='ed'
past_tense.append(i)
else:
i[-1] == 'e'
i +='d'
past_tense.append(i)

print(past_tense)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment