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

Yan Chan
Yan Chan
1,940 Points

Not sure what I have done wrong...

Please could you have a look at my codes?

disemvowel.py
def disemvowel(word):
    vowel=["a","e","i","o","u"]

    for letter in vowel:
        try:
            word.remove(letter)
        except ValueError:
            pass

        try:
            word.remove(letter.upper())
        except ValueError:
            pass

    return word

1 Answer

Steven Parker
Steven Parker
229,644 Points

You're applying remove to a string, but it's a method for lists.

Also, you'll need to account for words that have more than one of the same vowel, but the remove function only removes the first occurrence.

Perhaps you intended to use replace instead?