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

Prem Yadav
Prem Yadav
7,346 Points

not able to solve this problem......

hey there In this program i have created a list for word and used try and except for vowel removing. but still not able to solve. Not getting where i'm doing mistake. please help to find out solution.

disemvowel.py
def disemvowel(word):
    for letter in list(word):
        try:
            letter.remove('a') or
            letter.remove('e') or
            letter.remove('i') or
            letter.remove('o') or
            letter.remove('u')
        except ValueError:
            pass
        else:    
        return word

2 Answers

Aaron Nolan
Aaron Nolan
5,714 Points

This one can be quite tricky as I see a lot of people ask questions about this question specifically so you're not alone :)

The problem isn't so obvious but you shouldn't iterate over a list that you are also modifying as it can throw off the index and skip some letters. So instead you should try iterating over a copy of the list you are using!

If you need more help feel free to ask and happy coding :)

Prem Yadav
Prem Yadav
7,346 Points

can you please send me the code of program.........