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

Help with disemvowel(word):

The code won't pass please correct. I try running it on visual code, it prints out what I give it , minus the vowels of course. when i paste it on the platform, it raises a Bummer! Try again!

disemvowel.py
def disemvowel(word):
    '''Removes vowels from a word'''
    word_2 = word.lower()
    word_list = list(word_2)
    for letter in word_list:
        if 'a' in word_list:
            try:
                word_list.remove('a')
            except ValueError:
                print 'No more "a"s'
        if 'e' in word_list:
            try:
                word_list.remove('e')
            except ValueError:
                print 'No more "e"s'
        if 'i' in word_list:
            try:
                word_list.remove('i')
            except ValueError:
                print 'No more "i"s'
        if 'o' in word_list:
            try:
                word_list.remove('o')
            except ValueError:
                print 'No more "o"s'
        if 'u' in word_list:
            try:
                word_list.remove('u')
            except ValueError:
                print 'No more "u"s'


    word = ''.join(word_list)
    return word

1 Answer

First, your code shouldn't print anything. It will just confuse the challenge.

Second, you aren't checking for A, E, I, O and U. You are checking for the lowercase aeiou, but you also need to check for the uppercase forms. To Python, "a" and "A" are almost opposite letters! (Not kidding, the Python alphabet is "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" so "A" is almost on the other side of the alphabet)