Anti vowel


#1



def anti_vowel(text):
    index = 0
    while index <len(text):
        if text[index] in "aeiuoAEIOU":
            text = text.replace(text[index], "")
            index = index+1 if index > 0 else 0
        index += 1
    return text


i am getting this error:
Oops, try again. Your function fails on anti_vowel("Yab Gab to Trab Yab Yab Aeiouz"). It returns "Yb Gb t Trb Yb Yb eiz" when it should return "Yb Gb t Trb Yb Yb z".



#2

you are pretty close, here:

index = index+1 if index > 0 else 0

after replacing, you have an index shift, so you want to do index-1 so you make sure succesive vowels aren't skipped


#3

Would you mind running through the if statement please? This is where I get lost.


#4

in can be used to check if someting is present in a list or string, you can also write your own loop of course


#6

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