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

Aaron Fry
Aaron Fry
826 Points

Why do I get a EOF error on this code

It works on other programs

disemvowel.py
VOWEL_LIST = ["a", "e", "i", "o", "u",]

# Removes vowels in words
def disemvowel(user_word):
    # for the character in the list
    for vowel in user_word:
        if vowel in VOWEL_LIST:
            while vowel in user_word:
                user_word.remove(vowel)
        else:
            continue
    return ''.join(user_word)


while True:
    user_word = input("Type one word:\n"
                  "> ")
    if user_word.upper() == 'QUIT':
        break
    user_word_list = list(user_word.lower())
    print(disemvowel(user_word_list))

1 Answer

Fatemah Tavakoli
Fatemah Tavakoli
13,797 Points

I think becouse the challenge is asking to just write the function which does what they are asking. In your case some of the stuff is happening outside the function. Although you get the result that challenge wants, but it is not inside the function.

# Removes vowels in words
def disemvowel(user_word):
    # for the character in the list
    VOWEL_LIST = ["a", "e", "i", "o", "u"]
    for vowel in user_word:
        if vowel.lower() in VOWEL_LIST:
            user_word = user_word.replace(vowel, "")
    return user_word

I have modified your code as above.

Aaron Fry
Aaron Fry
826 Points

Thank you for you comment. I did finally realize that they will give the input but it wasn't very clear on that point. Thank you!