I tried to be as clear as possible in the title, but it was difficult to explain it briefly. I have to remove all vowels from a specific line; To do this, I made a loop that goes through a list of characters from this line, removes the vowels and then appends them:
def anti_vowel(text):
vow = ["a", "e", "i", "o", "u"]
chars = []
for i in text:
chars.append(i)
for i in chars:
if i.lower() in vow:
chars.remove(i)
return "".join(chars)
The problem is that when I run the code, there will always be a vowel that is not deleted. Examples:
>>> anti_vowel("Hey look Words!")
Hy lk Words!
>>> anti_vowel("Frustration is real")
Frstrton s ral
I am by no means an expert in Python, but this is confusing. Why would he delete a few letters and keep others, even if they are exactly the same?
source
share