Anti_Vowel? Why doesn't this work?


#1



https://www.codecademy.com/courses/python-intermediate-en-rCQKw/1/2?curriculum_id=4f89dab3d788890003000096#


Can someone explain to me why this code doesnt work? But when i add
but when i add

if x is not in letters:
word += x
return x

It chooses to work? Whats the main difference here.

def anti_vowel(text):
    letters = "aeiouAEIOU"
    word = ""
    for x in text:
        if (x != letters):
            word += x
    return x


#2

This will probably never be true, it is comparing it to an entire list.

Example:

5 != [5, 6, 12, 21345]

#3

Ahhh is there a better alternative i could have used rather than if x is not in letters?

For some reason i couldn't remember that method by myself, and the first thing i resorted to was !=


#4

I would use (not much shorter):

x not in letters:

You don't need the is keyword in there. :slight_smile: