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

Jeremy Macdonald
Jeremy Macdonald
238 Points

product_idea

When I run this code in the terminal, it works just fine. I can figure out what is wrong with it.

suggestinator.py
def suggest(product_idea):
    if len(product_idea) <= 3:
        raise ValueError("Ideas must be longer than 3 characters")
    return product_idea + "inator"

try:
    new_idea = input("What is your new idea?  ")
    idea = suggest(new_idea)
except ValueError as err:
    print("Oh no! Your idea needs more characters. Try again...")
    print("({})".format(err))
else:
    idea = suggest(new_idea)
    print("{}, what a great idea!".format(idea))

1 Answer

The suggest function by itself will pass the challenge.

Using input() in the challenges when it is not mentioned in the challenge instructions usually fails the challenge, since the checker does not provide input for it..

Jeremy Macdonald
Jeremy Macdonald
238 Points

Thank you. I was so confused. I kept checking it and knew it worked.