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

I'm trying to solve the Disemvowel challenge with `try`

I'm trying to solve the challenge using try and except

But it seems there is something that I am missing

disemvowel.py
def disemvowel(word):
    letters = list(word)
    vowels = ["a", "e", "i", "o", "u"]
    for i in vowels:
        upper = i.upper()
        if i in letters or upper in letters:
            try:
                letters.remove(i)
            except ValueError:
                print("No Vowels here")
            return letters
        word = ''.join(letters)
        return word
    return word

2 Answers

you have three returns, you only need one. the program exits when it hits a return, so it's exiting earlier than is necessary to remove the vowels.

I've tried removing the returns, but it still wont't run

You are testing for lowercase (i) and uppercase (upper) vowels, but only trying to remove the lowercase ones remove.(i) so you could be trying to remove the letter 'e' from the word 'Error'.