Anti-vowel


#1



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


Hello, I am getting some type of list object error when I run the code for this exercise:
Oops, try again. Your code looks a bit off--it threw a "'list' object has no attribute 'join'" error. Check the Hint if you need help!

Can anyone help identify the source of the problem? Thanks!


def anti_vowel(text):
    vowels = "aeiouAEIOU"
    my_output = []
    
    for char in text:
        if char not in vowels:
           my_output.join(char)
    print my_output


#2

Hi @mhernandez58,

join is not a list method. Use append here ...

my_output.join(char)

Then, pass my_output to the join method after the loop. In doing so, call the join method from an empty str, '', to produce and return the result. printing the result from within the function does not suffice.


#3

Thank you. I've made the tweaks, and am closer, but a new error message is appearing. It appears the loop is not iterating through all the characters in (text):

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

def anti_vowel(text):
vowels = "aeiouAEIOU"
my_output = []

for char in text:
    if char not in vowels:
       my_output.append(char)
       return my_output
"".join(my_output)

#4

Here, you are returning my_output within the loop, before the result has been completed ...

        return my_output

That line should be removed.

You have computed the result here ...

    "".join(my_output)

... but you have not returned it.


#5

Thank you very much!


#6