Help with anti_vowel code


can someone please check the code below?
when i manually put a print statement it removes the vowels in the editor, but the editor puts out a message that it would print out bcdHy lk Wrds!. when i enter the command print anti_vowel("Hey look Words!") it prints it correctly in the editor but still the message that my code did not pass, can anyone help me with this?

thank you,

def anti_vowel(text):
for i in text:
if check_vowel(i):
return "".join(a)

def check_vowel(i):
if i in "aeiouAEIOU":
return False
return True

print anti_vowel("Hey look Words!")


I found the solution in another thread, that the list needs to be in the function i don't understand exactly why but it works that way.
here is the link to the answer.


Hi, I am a new Python same as you.Below code is for your reference.You may think about it and help you.

def anti_vowel(text):
vowel = []
for i in text:
for i in vowel:
if i in "aeiouAEIOU":
text = vowel
return "".join(text)

print anti_vowel("Hey look Words!")


I can't figure out what's wrong with my code. Especially because the output is so close to what it should be:

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


def anti_vowel(text):
    text = list(text)
    for char in text:
        if char in "aeiouAEIOU":
    return ''.join(text)


Yes, this does look strange, but the answer is that your for is moving up the string while your remove function shortens the string.
so every time you are deleting a vowel, the next char you are not checking because the list moved up.
for example if you check just the word "load", your for will check "l" and it will be ok > it will check "o" and will remove and shorten your string so it will not check "a" but will check "d" and you will be left out with "lad".
hope this helps.