Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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

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

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

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

1 Answer

Chris Freeman
Chris Freeman
Treehouse Moderator 67,893 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!!!