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

Jesse Ferguson
Jesse Ferguson
1,419 Points

I'm stuck

I don't know how to do this

disemvowel.py
def disemvowel(word):
    try:
        word.remove('a')
        word.remove('A')
        word.remove('E')
        word.remove('e')
        word.remove('I')
        word.remove('i')
        word.remove('O')
        word.remove('o')
        word.remove('U')
        word.remove('u')
    except ValueError:
        pass
    return word

1 Answer

Chris Freeman
MOD
Chris Freeman
Treehouse Moderator 68,441 Points

Your approach doesn't handle these cases:

  • if the word is a string, strings do not have a remove method
  • any vowel appearing more than once will not be removed
  • if any vowel is not found the try block to exit then return the current state of word

Suggestion: convert the word to a list then use a for loop to extract the non-vowels rejoin the non-vowels back into a string and return it.

Post back if you need more help. Good luck!!!