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

Hi, This is challenge task. The below code works well in Workspace , but throws an EOF error when used inside challenge

def disemvowel(word): word = input("Tell me a word:") print("The word you entered is: {} ".format(word)) word_list = list(word) vowel = "aeiouAEIOU"
for letters in vowel: try: word_list.remove(letters) except ValueError as err: continue

word = "".join(word_list) print("The word after removing vowels looks like: {}".format(word)) return word

disemvowel("word")

disemvowel.py
def disemvowel(word):
  try:
    word = input("Tell me a word:")
  except EOFerror as err:
    print("No input received")
  print("The word you entered is: {} ".format(word))
  word_list = list(word)
  vowel = "aeiouAEIOU"
  for letters in vowel:
    try:
      word_list.remove(letters)
    except ValueError as err:
      continue
  word = "".join(word_list)
  print("The word after removing vowels looks like: {}".format(word))
  return word

disemvowel("word")

I tried it in a workspace and entered 'cheese' and the vowels weren't removed.

Tell me a word:cheese
The word you entered is: cheese
The word after removing vowels looks like: chese

1 Answer

Thanks Kris. I will update my code.