Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Python Collections (2016, retired 2019) Lists Disemvowel

Alexander Bilton
Alexander Bilton
1,982 Points

Disemvowel function - I can't see where this goes wrong

I am looping through the word and appending to a new list if the letter is not in my list of vowels, but I keep getting an error..

Any help is appreciated

disemvowel.py
def disemvowel(word):
    lst = ['a','e','i','o','u','A','E','I','O','U']

    word_without_vowels = []

    for letter in word:
        if letter not in lst:
            word_without_vowels.append(word(letter))

word = ''.join(word_without_vowels)
return word

4 Answers

james south
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
james south
Front End Web Development Techdegree Graduate 33,271 Points

your last two lines aren't actually in the function. they need to be indented a tab to be in the function block. then in your for loop, where you have word(letter) throws an error. letter is your loop variable so you can append it directly.

Alexander Bilton
Alexander Bilton
1,982 Points

Great feedback, James - Thank you! Worked perfectly.

Tom Miller
Tom Miller
2,640 Points

Also, really basic question, but why is it

''.join(...)

and not

', '.join(...)?

I can't seem to get Workspaces running to test how an argument flows through the function, so I'm having to do it all in my head.