I've tried to be as clear as possible in the title but it was kind of hard to explain it briefly. I have to remove all the vowels from a certain string; to do that, I made a loop that goes through a list composed of the characters of that string, removes the vowels and then joins 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 doesn't get deleted. Examples:
>>> anti_vowel("Hey look Words!")
Hy lk Words!
>>> anti_vowel("Frustration is real")
Frstrton s ral
I'm in no way an expert in Python but this is confusing. Why would it delete some letters and keep others, even if they're exactly the same?