Anti_vowel with list


Hi Everyone,

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

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:
            anti_v += x
    return anti_v



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


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