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

solution for suggestinator exercise

suggestinator.py
def suggest(product_idea):
    return product_idea + "inator"
product_idea = input("Product idea please ")

if len(product_idea) < 3:
    raise valueError("Product idea is invalid")

Cant get this to work any suggestions, please?

1 Answer

boi
boi
14,242 Points

The challenge wants you to raise an exception if the product_idea argument is less than three characters long. You got it right, sorta..., take a look at the code below.

def suggest(product_idea):  👈#input parameter already provided (product_idea)
    return product_idea + "inator"
product_idea = input("Product idea please ")  👈#You don't need an input for product_idea, the FRIST line of code
                                                #already handles the input, thier is an input parameter provided already

if len(product_idea) < 3:  👈# This is correct but should be inside of a function, hint(def suggest)
    raise valueError("Product idea is invalid")  👈# This is correct but should be inside of a function, hint(def suggest)

Try to make these changes, if the problem persists post back here.