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

Can you please raise a ValueError if the product_idea is less than 3 characters long? product_idea is a string. Thanks i

''' def suggest(product_idea): return product_idea + "inator" if product_idea <= len("product_idea") * 3: raise valueError("you idea is too short") '''

def suggest(product_idea):

if len(product_idea) < 3 :

raise ValueError ("......")

return product_idea + "inator"

you just had the "if" statement in the wrong place.

2 Answers

Steven Parker
Steven Parker
243,656 Points

Stephen is right that you need to have the test and raise before the return, but you have a couple of other issues:

  • test the length directly, don't multiply it by anything
  • compare the length of the new string to the number 3 instead of itself
  • when referencing a variable (such as product_idea), never put quotes around the name

Thanks Stephen and Steven!