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

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 67,515 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!!!