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

suggestinator.py sorry I'm stuck again.

suggestinator.py
def suggest(product_idea):
    return product_idea + "inator"
if product_idea < len(3):
    raise ValueError("Is your product idea only 3 characters long?")
Pratham Mishra
Pratham Mishra
14,191 Points

check the condition first, in the condition block raise the ValueError and then return the final string.

1 Answer

Steven Parker
Steven Parker
231,269 Points

You've got the right idea, but there are a few issues:

  • all code in a function must be indented
  • the conditional code must be done before the return
  • compare the length of the argument to 3, instead of the argument to the length of 3