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

suggestinator.py sorry I'm stuck again.

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
13,537 Points

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

1 Answer

Steven Parker
Steven Parker
217,570 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