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

Douglas Brunson
PLUS
Douglas Brunson
Courses Plus Student 2,458 Points

My code is not working. I'm using try/except blocks or each of lowercase or uppercase vowels (ten try/except total)

My try/except blocks are withing a while loop that loops until no more vowels are in my_list, where my_list is the word string turned into a list. When I try to check it, I get a message that says it took to long for my code to run.

disemvowel.py
def disemvowel(word):
    word_list = list(word)
    while 'a' or 'A' or 'e' or 'E' or 'i' or 'I' or 'o' or'O' or 'u' or 'U' in word_list:
        try:
            word_list.remove('a')
        except ValueError:
            pass
        try:
            word_list.remove('A')
        except ValueError:
            pass
        try:
            word_list.remove('e')
        except ValueError:
            pass
        try:
            word_list.remove('E')
        except ValueError:
            pass
        try:
            word_list.remove('i')
        except ValueError:
            pass
        try:
            word_list.remove('I')
        except ValueError:
            pass
        try:
            word_list.remove('o')
        except ValueError:
            pass
        try:
            word_list.remove('O')
        except ValueError:
            pass
        try:
            word_list.remove('u')
        except ValueError:
            pass
        try:
            word_list.remove('U')
        except ValueError:
            pass
    word = []
    for item in word_list:
        word = word + item
    return word