I want to remove every word in the list words that end in a vowel. Here is the code that I have:
words = ["hi", "hello", "when", "what"]
for word in words():
if word[-2] == "a" or word[-1] == "e" or word[-1] == "i" or word[-1] == "o" or word[-1] == "u":
words.remove(word)
print(word)
The output should be:
when
what
But the code is just printing all the words.
New contributor
Harish Alagappan Ramanathan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.