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 Need help on the "Raise a exception "quiz

Hello guys, lately I Have tried every single method to Achieve the whole lesson. i perfer seeing the whole solution.

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

1 Answer

Chris Freeman
MOD
Chris Freeman
Treehouse Moderator 68,441 Points

You are very close! You need to check the length of the passed in argument instead of checking the length of the fix string "dende”.

Post back if you need more help. Good luck!!!

I'm sorry to say but I Tried doing that. it might be that I Don't get what you mean by "Arguments". So can you give me a little hand here please?. that'll be appreciated :D

Chris Freeman
Chris Freeman
Treehouse Moderator 68,441 Points

There are two general terms referring to data passed to a function: parameter and argument

When defining a function, the parameters are listed in parens following the name of the function. Below, product_idea is the parameter:

def suggest(product_idea):

When a function is called, a list of arguments are listed in parens followers no the function name. If no argument are supplied, the parens are empty.

# calling function 
suggest('cake')

# should return β€œcakeinator”

The code challenge checker will call your function with various arguments to evaluate its behavior. Since your code does not utilize the product_idea parameter, using instead a fixed string "dende”, then the length Idea will always 5 and the ValueErrror would never be raised.

    Idea = len("dende") # always 5
    if Idea < 3:  # always False

So, replace "dende" with product_idea