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

Michael Revy
Michael Revy
3,882 Points


I get Bummer! Hmm, got letters did not expect - or similar.
I loop thru vowel list and while I can find vowels in the word, I remove, then on to next vowel. I also force lowercase.

def disemvowel(word):
    disem = list(word.lower())
    vowels = ["a", "e", "i", "o", "u"]

    for i in range(len(vowels)):
        while True:
            except ValueError:

    return ''.join([i for i in disem])

word = "CaaaPgZZUUiRfseEYooOj"
cipher = disemvowel(word)
Michael Revy
Michael Revy
3,882 Points

I entered a very elegant solution (not my own - Brandon Jaus)

def disemvowelb(word): return ''.join([i for i in word.lower() if not i in 'aeiou'])

but this still gives me the Bummer! I tested with several long words and seemed to work fine.

Michael Revy
Michael Revy
3,882 Points

I see my mistake .. I should not lower case any consonants !!! Removed lower and added uppercase vowels

Help man me with full working code I'm stack man its been days please help!!!

1 Answer

Stuart Wright
Stuart Wright
41,103 Points

I have amended the one line solution you've posted a little to get the correct solution:

def disemvowel(word):
    return ''.join([i for i in word if not i in 'aeiouAEIOU'])

Can yu help me with full working code please!!