I get a funny error message for this:

Oops, try again. Your function fails on anti_vowel("Hey look Words!"). It returns "Hy lk Words!" when it should return "Hy lk Wrds!".

It removes the first two "o"s but not the third. Any ideas?

def anti_vowel(text):
    listed = list(text)
    for letter in listed:
        if letter in "aeiouAEIOU":
    concatenated  = "".join(listed)
    return concatenated


the problem with this solution is index shift because you remove from the same list as you are looping over

the moment the first o of look gets removed, everything to the right of the removed character shifts one index to the left because lists can't have empty indexes, then the loop moves on to the next index, which causes problems

the solution would be not to loop over the same list as you are removing from, so you could loop over the string (text) while removing from the list


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.