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

The code I wrote for the "Raise an Exception" (python) code challenge works. Why I get the "bummer" message?

suggestinator.py
def suggest(product_idea):
    return product_idea + "inator"def suggest(product_idea):
    if len(product_idea) < 3:
        raise ValueError("Length less than 3")
    return product_idea + "inator"

try:
    new = input ("Whats your idea? ")
    idea = suggest(new)
except ValueError as err:
    print("Oh no!")
    print("({})".format(err))
else:    
    print("Your idea is: ",idea)   

2 Answers

Steven Parker
Steven Parker
231,275 Points

All the challenge wants is for you to add a test and raise to the function. You don't need a "try" or "except", and you won't need to "input" anything or "print" anything.

Also note the syntax error on the 2nd line where the first part of the function appears to be repeated.

Your suggestion worked. A simpler solution is what the challenge wanted. THANKS. But, I do see the syntax error on the 2nd line. Can you point that out to me?

Thank you very much for your input. I guess I gave it more than it wanted. THX