Anti_vowel


#1



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":
            word.append(x)
        
    print "".join(word)
    return "".join(word)


#2

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

That line is not expected.


#3

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.


#4

Thank you I figured it out!


#5

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