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

I've made a function that creates brand new product names using "artificial intelligence". I have a problem though, pe

what to do here.Can somebody please help

suggestinator.py
def suggest(product_idea):
    if product_idea <= 3:
        raise ValueError("Need a longer idea.")
    return product_idea 

2 Answers

Steven Parker
Steven Parker
231,269 Points

You're getting close, but:

  • the "product_idea" is a string and cannot be compared to a number, check the length (len) of it instead
  • don't change the code provided (particularly where it creates the "return" value by concatenation)
Shahla Jalali
Shahla Jalali
589 Points

how would you write that?

if product_idea (len)<=3

Steven Parker
Steven Parker
231,269 Points

Almost. "Len" is the function name, "product_idea" is the argument you pass to it.

    if len(product_idea) <= 3: