Okay...I have never posted on here before, but I need some help. I was trying to do this exercise without coming to the Q&A, to just do it with what I could remember off the top of my head. With that said, I see now that I went about this a more difficult and obviously wrong way. I've seen what I did wrong, but I still don't understand why what I have won't work and was hoping that someone could take a look and explain what is happening because it's not doing what I thought it would do apparently. I'm getting the following error:
Oops, try again. Your function fails on anti_vowel("Hey look Words!"). It returns "Hy lk Words!" when it should return "Hy lk Wrds!".
I am thinking that my code is running each character in (text) through the loop individually and removing it if it matches but it stops after removing three vowels and it leaves the fourth. It has already removed two 'o' and I'm stuck as to why it leaves the last one.
Even though this isn't the correct answer to the practice, I'd still like to understand why it isn't working and know what I did wrong...
def anti_vowel(i): i = list(i) for ltr in i: if ltr == "a" or ltr == "A": i.remove(ltr) elif ltr == "e" or ltr == "E": i.remove(ltr) elif ltr == "i" or ltr == "I": i.remove(ltr) elif ltr == "o" or ltr == "O": i.remove(ltr) elif ltr == "u" or ltr == "U": i.remove(ltr) text="".join(i) return text