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

My code works fine in my own terminal

No errors when I run this on my own machine

suggestinator.py
def suggest(product_idea):
    if len(product_idea) < 3:
        raise ValueError("Too short!")
    return product_idea + "inator"
try:
    idea = input("Your idea: ")
    product_name = suggest(idea)

except ValueError as err:
    print("Try again - {}".format(err))
    #print("{}".format(err))
else:
    print("Your product name: {}".format(product_name))
Jeremy Charles
Jeremy Charles
Courses Plus Student 643 Points

Your code works with your function definition alone. I'm not sure what tests they are throwing at your code that would cause it not to pass.

2 Answers

Steven Parker
Steven Parker
229,732 Points

Much of this code seems to be your own version of a validation system, which isn't needed in the challenge itself (and confuses it!).

For the challenge, the instructions only ask you to change the function itself. You won't need to call it, or use "try" or "except", or to "input" or "print" anything.

challenge only requires you to change the product idea if: statement

def suggest(product_idea): if product_idea < "abc" : raise ValueError("too short") return product_idea + "inator"