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

Gilang Ilhami
Gilang Ilhami
12,045 Points

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

james south
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
james south
Front End Web Development Techdegree Graduate 33,271 Points

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.

Gilang Ilhami
Gilang Ilhami
12,045 Points

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

Tom Miller
Tom Miller
2,640 Points

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'.