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

Lochie McCorry
Lochie McCorry
2,471 Points

stuck on this raise an exception question

No idea what I am doing wrong could someone please help?

suggestinator.py
def suggest(product_idea):
    if product_idea = < 3:
        raise ValueError("You idea needs to be bigger")
    return product_idea + "inator"
Gabriel Flanagan
Gabriel Flanagan
Courses Plus Student 1,574 Points

I'm in the exact same boat. No matter how many different variations of code I try, nothing seems to work

1 Answer

Hi Lochie,

  • double-check your ordering of the = and < operands - < or > always go before the =. It's written exactly as you'd say it, so that should be a helpful reminder e.g. "x is less than or equals to y".
  • ints or floats can't be combined with strings using the + operand; Python has no way of knowing whether you want to add the number to the front of the string, or you tried to add a string to a number by mistake. A great way to solve this is the "{}".format() function:
return "{}inator.".format(product_idea )