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

Consistent EOF Error in Raising Exception Challenge

Hey all! I'm not sure if I'm just misunderstanding the challenge, but I really want to learn this as I'm very interested in a career in code. When I define a value for product_error beforehand, it always returns an error where they "passed a and didn't get a ValueError." But when I make product_error able to be defined, it passes an EOF error. Here's the code I'm using now that's returning the EOF error. Sorry in advance if it's a quick and obvious fix!

def suggest(product_idea):
    return product_idea + "inator"

try:
    product_idea = input("Suggest  ")
    if len(product_idea) < 3:
        raise ValueError("Please choose a name more than three characters!")
except ValueError as err:
    print(("({})".format(err)))
else:
    suggest()

2 Answers

Steven Parker
Steven Parker
229,982 Points

You're working way too hard! You only need to add a conditional test and the "raise" to the function. You don't need to "input" or "print" anything; and you won't need a "try", "except", or any code after the function.

Also, in future questions remember to include a link to the course page. :wink:

Thank you for the answer! I'll also be sure to keep the link thing in mind as well!

i’m not 100% sure but u didn’t put “ at the right place in the beginning of the print statement. print(“whatever is here”)