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

This code works in my machine and removes all of possible combinations of vowels I could think of. Please help.

I am running this code with following main function.

def main(): print(disemvowel("Something") + "\n" +disemvowel("Nothing") + "\n" +disemvowel("Keyur") + "\n" +disemvowel("Golani") + "\n" +disemvowel("Coconut") + "\n" +disemvowel("JavaChipFrapechino") + "\n" +disemvowel("Coffee") + "\n" +disemvowel("Jacket") + "\n" +disemvowel("Rhythm") + "\n" +disemvowel("Nudity") + "\n" +disemvowel("GoHome"))

main()

And it is giving following output.

Smthng Smthng Nthng Kyr Gln Ccnt JvChpFrpchn Cff Jckt Rhythm Ndty GHm

Please suggest what is it that I'm doing wrong.

disemvowel.py
def disemvowel(word):
    word_list = list(word)
    for letter in ["a", "e", "i", "o", "u"]:
        while True:
            try:
                word_list.remove(letter)
            except ValueError:
                break
            else:
                continue
    word = "".join(word_list)
    return word

2 Answers

Steven Parker
Steven Parker
231,269 Points

:point_right: Perhaps you must also remove UPPER CASE vowels.

Try something like "Apple". :smile:

Aah crap. That's really annoying to keep missing this kind of small stuff. Anyways thanks a lot for the help.