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 Basics Functions and Looping Raise an Exception

adrian dc
adrian dc
402 Points

problem with solution code

Can anyone tell me what is wrong with my code for this particular challenge? Also, why do I get an EOF error using input

suggestinator.py
def suggest(product_idea):
    if len(product_name)< 3:
        raise ValueError("Length of the word is less than three characters long")
    grand_total = str(product_idea) + "inator"
    return grand_total
try:

    product_name = input("Enter a product string")
    final_name = suggest(product_name)

except ValueError as err:
    print("That is not a correct entry")
    print("{}".format(err))
else:
    print("The product name is {}".format(final_name))                         

1 Answer

Chris Freeman
MOD
Chris Freeman
Treehouse Moderator 68,423 Points

The code from the input statement to the end should be removed as it confuses the checker.

The function should only reference the parameters. The challenge checks behavior by calling the function. It does not have data to feed an input statement when it is not expected. So the EOF is from unexpectedly reaching the end of the *behavior check” script, not necessarily the end of your code.

Post back if you need more help. Good luck!!!