Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Python Python Collections (2016, retired 2019) Lists Disemvowel

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

Problem with code

Not sure why this doesn't work. Perhaps too long?

disemvowel.py
def disemvowel(word):
    word_list = list(word)
    while 'a' in word_list or 'A' in word_list or 'e' in word_list or 'E' in word_list or 'i' in word_list or 'I' in word_list or 'o' in word_list or 'O' in word_list or 'u' in word_list 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