Skip to content

Instantly share code, notes, and snippets.

View swarba015's full-sized avatar

Nuzhat Zahan swarba015

  • United State
  • 16:34 (UTC -05:00)
View GitHub Profile
@swarba015
swarba015 / Python_ accumulation pattern practice code
Created November 6, 2022 06:18
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 = i+ "d"
past_tense.append(i)
else:
i = i + "ed"