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

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.)