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

Mohsan Chaudhry
Mohsan Chaudhry
1,469 Points

Code words in workspace, but not for exercise

I tried this code in workspaces and it worked. But I'm not passing the test. I'm not sure where I'm making the error.

Thanks for the help

disemvowel.py
def disemvowel(word):
    word_list = list(word)
    index = 0
    for index in range(len(word_list)):
        if 'a' in word_list:
            word_list.remove('a')
        elif 'e' in word_list:
            word_list.remove('e')
        elif 'i' in word_list:
            word_list.remove('i')
        elif 'o' in word_list:
            word_list.remove('o')
        elif 'u' in word_list:
            word_list.remove('u')
        else:
            index += 1
            continue
    new_word = ''.join(word_list)
    return new_word

3 Answers

Chris Freeman
MOD
Chris Freeman
Treehouse Moderator 68,453 Points

You are very close. Be sure to check for upper AND lower case vowels!

Chris Freeman
Chris Freeman
Treehouse Moderator 68,453 Points

While a brute force approach works, please explore the other solutions for this challenge here

Mohsan Chaudhry
Mohsan Chaudhry
1,469 Points

I tried to make the word all lower case before it goes into the loop in 2 different ways, both of which didn't work.

word_lower = word.lower() word_list = list(word_lower)

or

word_list = list(word.lower())

Thank you for your help!

Chris Freeman
Chris Freeman
Treehouse Moderator 68,453 Points

I tried a brute force test of expanding the if/elif code to also check for the uppercase versions and it passes the challenge.

Mohsan Chaudhry
Mohsan Chaudhry
1,469 Points

Thanks for the help! It worked after I added more elif statements to check for uppercase.