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

Alexey Serpuhovitov
Alexey Serpuhovitov
6,931 Points

It's not clear what conditions should be met to pass the challenge.

Does anyone know?

Second. Here is my solution. Is it good? What to change?

disemvowel.py
def disemvowel(word):
    vowels_to_remove = ["a", "e", "i", "o","u"]
    word_list = list(word)
    for vowel_to_remove in vowels_to_remove:
        while True:
            try:
                word_list.remove(vowel_to_remove)
            except ValueError:
                break
        while True:
            try:
                word_list.remove(vowel_to_remove.upper())
            except ValueError:
                break
    word = ''.join(word_list)
    return word

1 Answer

Steven Parker
Steven Parker
231,236 Points

Your code seems to pass the challenge as-is! :+1:

You have obviously met all the conditions.

It would make no difference to passing the challenge, but if you wanted to make the code more compact you could eliminate one of the loops if you add uppercase vowels to the vowels_to_remove list.