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

Kelcey Wilson
Kelcey Wilson
15,738 Points

Previous code challenge EOFError: EOF when reading a line (Spoiler)

I had the following answer to the code challenge that worked everywhere but in your workspace, where I kept getting the above error referring to line 6 (the input line):

def suggest(product_idea):
    if len(product_idea) <= 3:
        raise ValueError("Make it more than 3 characters.")
    return product_idea + "inator"
try:
    product_idea = input("What's your product idea? ")
    inator = suggest(product_idea)
except ValueError as err:
    print("That's not long enough")
    print("{}".format(err))
else:
    print(inator)'

Searching stackoverflow I pieced together a solution by adding the following lines:

except EOFError as error:
    print("{}".format(error))

Can anyone explain what I am doing wrong, or if my solution is correct, where I missed it being covered in the videos?

Thanks!

1 Answer

Chris Freeman
MOD
Chris Freeman
Treehouse Moderator 68,423 Points

The issue is the use of input. The challenge checker does not expect interactive elements. The checker reads in all of the solution code first. Since the try statement is not in a function, it is executed immediately which pauses reading the code while waiting for an input that will never come. I suspect the EOF error is an artifact of a behind-the-scenes activities with the checker.

Post back if you have more questions. Good Luck!!