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

Disemvowel

Hi All

Can anyone figure out why this code isn't passing the test?

I've run the script within a console. And it does as expected - It removed all vowels from the word provided.

Thanks in advance.

disemvowel.py
def disemvowel(word):
    new_word = list(word.upper())

    vowels = ['A','E','I','O','U']

    for e in vowels:   
        if e in new_word:
            new_word.remove(e)
    word = "".join(new_word)

    return word

2 Answers

Hi, I think the problem is that you convert the word to uppercase letters. So the returned word is in uppercase, which is the problem.

code the function so that the vowels-list contains lowercase vowels aswell as uppercase

Surely it should still be accepted though. As everything is converted to uppercase before the loop is initiated.

I'll add the lowercase vowels to the list as well then. I just figured it would be more efficient (less key-strokes) to do it like that.