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

Erkindjon Pulatov
Erkindjon Pulatov
1,082 Points

Where is my error? I can not understand

suggestinator.py
def suggest(product_idea):
    product_idea = input("Please enter product idea!")
    if (len(product_idea) < 3):
        raise ValueError("product name should have at least 3 characters")
return product_idea + "inator"
Erkindjon Pulatov
Erkindjon Pulatov
1,082 Points

I did 4 spaces on last line, still is not working

1 Answer

Josh Icenogle
Josh Icenogle
9,257 Points

It's just a syntax error your if statement should be like this: if len(product_idea) < 3: Also your return should be indented four spaces so it is still inside the function. Also remove the input on line 2 and you should be golden (:

Chris Freeman
Chris Freeman
Treehouse Moderator 68,423 Points

The parens around the if condition are not a syntax error, they are unnecessary with a simple conditional, as in this case.

The other two errors are correctly identified. Thanks for helping answer questions on the forum!!