Anti_vowel with list


#1


Hi Everyone,

What is wrong with my anti_vowel code below...here's the link and error message


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

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


def anti_vowel(text):
    anti_v = ""
    vowel = ['a', 'e', 'i' , 'o' , 'u' , 'A' , 'E' , 'I','O','U']
    for x in text:
        if x == vowel:
            continue 
        else:
            anti_v += x
    return anti_v


#2

here:

if x == vowel:

x is a character from your text string, where vowel is a list. A single character will never equal a list.

to achieve what you want do do here, you need the in keyword, which can check if a character is in a list


#3

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