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

Jake Liebetrau
seal-mask
.a{fill-rule:evenodd;}techdegree
Jake Liebetrau
Python Development Techdegree Student 763 Points

Unsure why I receive the error as follows: Error: test_exception_not_raised (_main_.TestRaiseExcecution)

suggestinator.py
import math

def suggest(product_idea):
    if len(product_idea) < 3:
        raise ValueError("Please try again.")
    return product_idea + "inator"

try:
    product_idea = input("What is your product name?    ")
    new_name = suggest(product_idea)
except ValueError as err:
    print("Oh no! At least 3 characters are required to create a name")
    print("({})".format(err))
else:
    print("The brand new product name is {}".format(new_name))
Jake Liebetrau
seal-mask
.a{fill-rule:evenodd;}techdegree
Jake Liebetrau
Python Development Techdegree Student 763 Points

I've discovered the correct way to complete this challenge but I am still interested in why I had the error for the rest of the code.

1 Answer

Chris Freeman
MOD
Chris Freeman
Treehouse Moderator 68,441 Points

Hey Jake Liebetrau, the error you see is caused by the input statement. The checker executes your code with specific expectations. When the checker hits an unexpected input statement, it doesn’t have any input to offer so the checker effectively hangs. The error you see is raised by internal checker code.

Post back if you need more help. Good luck!!!