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

Marc Vilar
Marc Vilar
8,230 Points

problem with grader

Even with code from internet and that I think it's doing what is supposed to, getting the

"Hmm, got back letters I wasn't expecting!"

Don't know why.

disemvowel.py
def disemvowel(word):
    vowels = 'aeiou'
    "".join([letter for letter in word.lower() if letter not in vowels])
    return word

5 Answers

Hi Marc Vilar, I’m actually not sure what’s wrong with your code but this worked for me:

def disemvowel(word):
    new_word = ""

    for character in word:
        if not character.lower() in "aeiou":
            new_word += character

    return new_word

EDIT: I figured it out. You’re doing it properly, but you forgot to return the joined string! You need to change the third line to reassign to the word variable like this:

def disemvowel(word):
    vowels = 'aeiou'
    word = "".join([letter for letter in word.lower() if letter not in vowels])
    return word

Hi hum4n01d long time no see :)

I'm xela888

Hello there :)

To add on to hum4n01d's answer, you need to also support uppercase vowels.

The challenge is also expecting "AEIOU" to be cut out of the string :smile:

You can fix this by adding .lower() to letter in the if part OR you can add "AEIOU" in uppercase to the vowels variable.

I hope this helps out. ~Alex

Ah yes, I accounted for this in my own solution

Marc Vilar
Marc Vilar
8,230 Points

Thanks all, guys.

Could you mark one of the answers as correct?

Marc Vilar
Marc Vilar
8,230 Points

Hi,

I marked one as best answer, isn't that what I had to do? If not, don't know how, sorry, if you can explain, I will do it.

No, you did it right but I posted my comment before you marked it :)

Marc Vilar
Marc Vilar
8,230 Points

ah, ok,

Thanks again for taking the time to reply my doubt.

No problem!