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

def suggest(product_idea): if product idea len( < 3 ): raise ValueError "product idea is less than 3 charact

Evening everyone!! Got stuck on this code, anyone able to help?

Many thanks!!

suggestinator.py
def suggest(product_idea):
    if product idea len( < 3 ):
        raise ValueError "product idea is less than 3 characters long"
    return product_idea + "inator"

3 Answers

Hi. Well I think that you missed the _ in product_idea, making it act as 2 different variables. Also, that line should be:

if len(product_idea) < 3:

Then below that, should be:

raise ValueError("product idea is less than 3 characters long")

Hope this helps!

Hey Robert!! Many thanks for your help!! You nailed it!!

Regards,

Luiz

Just be sure to check the labels/names to make sure they match

def suggest(product_idea):
    if product idea len( < 3 ): # product idea - should match wherever the parameter is used - product_idea
        raise ValueError "product idea is less than 3 characters long"
    return product_idea + "inator"

Also, since watching the video about raising exceptions and reading tracebacks I have been trying to read and watch everything about accurately understanding tracebacks. Not sure if this is allowed. If its not I apologize in advance. https://www.youtube.com/watch?v=3p3p6kp39to&t=293s <--- this really helped me

Cheers.