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

Thokozani Hove
Thokozani Hove
228 Points

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

please help on this umm stuck

suggestinator.py
def suggest(product_idea):
    if product_color < 3:
       raise ValueError("characters too short")

1 Answer

Steven Parker
Steven Parker
241,488 Points

Here's a few hints:

  • this code seems to be testing "product_color", but there's no variable or parameter with that name
  • the parameter name is "product_idea"
  • the test needs to check the length of the string
  • the part of the provided code that returns the value seems to have been removed (but needs to stay)
Thokozani Hove
Thokozani Hove
228 Points

ok thank u let me try again