What is wrong with my code below for anti_vowel?

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

def anti_vowel(text):
    for x in text:
        word = []
        x = x.lower()
        if x not in "aeiou":
    print "".join(word)
    return "".join(word)


Initialize the list outside of the loop so it is allowed to grow.

That line is not expected.


I would suggest making a list of the vowel's you want to filter (both cap and lower) outside of any loop cause it expected of you to return caps as caps and lower as lower (you lower the text thus no caps will be returned).
Then in your function use a one-liner with a for loop in it: return".".join([insert for-loop here]) that joins each x for x in text if not in vowels-list.


Thank you I figured it out!


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