Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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.