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

Adriano Junior
Adriano Junior
5,065 Points

DISEMVOWELing in Python Collections

I don't understand why my code is being rejected, in this Code Challenge. They said we could resolve it however we liked. And this works. I really don't see where is the problem. Can someone help?

disemvowel.py
def remove_all_vowels():
    word = list(input("Write any word you like: "))
    print("Your selected word is now: ", word)
    while True:
        vowel = input("Please insert the vowel you would like to be removed.\n(Vowels = a, e, i, o, u or A, E, I, O, U)\n> ")
        def disemvowel(word):
            try:
                word.remove(vowel)
            except ValueError:
                pass
            return word
        disemvowel(word)
        if vowel.upper() == "NONE":
            print("Your final word, without vowels, is: ", word)
            break
        print("You now have: ", word)
remove_all_vowels()

1 Answer

Why doesn't you code work? Well, let's see...

  • Why is your function called remove_all_vowels and not disemvowel?
  • Why are you inputting the word?
  • Why are you printing the result?
  • And a bajillion other reasons...

Read this other post. (You also might want to completely start over.)