Anti_vowel, why isn't my code working?


In my code am first converting the given string into a list and then removing the vowels using .remove()

For print anti_vowel("Hey You!") my code gives an output "h"

def anti_vowel(text):
    text = text.lower()
    sans_vowels = []
    for i in text:
    for i in sans_vowels:
        if i == 'a' or i == 'e' or i == 'i' or i == 'o' \
        or i == 'u':
           return i
    return sans_vowel


i don't recommend remove for this problem, it is a really great challenge to solve this problem with remove.

okay, now for the flaws in your code. First, understand that a function ends the moment a return keyword is reached, which happens in the first run of the loop:

           return i

thanks to the above code.

and this line:

return sans_vowel

you forgot the s after vowels

now the code will still not work, because of index shift thanks to remove. I recommend appending constants to a new list, a lot easier


Hey, I got it.
Thanks for the help.