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

Error Handling

The following code gives the below mentioned errors:

Code: def suggest(product_idea): if len(product_idea) < 3: raise ValueError("Idea is too short") return product_idea + "inator"

try: idea = str(input("What's your idea? ")) final_idea = suggest(idea) except ValueError as err: print("Not a good idea") print("({})".format(err)) else: print("{}".format(final_idea))

ERROR: test_exception_not_raised (main.TestRaiseExecution)

Traceback (most recent call last): File "", line 23, in test_exception_not_raised File "/workdir/utils/challenge.py", line 24, in execute_source exec(src) File "", line 7, in EOFError: EOF when reading a line

======================================================================

ERROR: test_exception_raised (main.TestRaiseExecution)

Traceback (most recent call last): File "", line 30, in test_exception_raised File "/workdir/utils/challenge.py", line 24, in execute_source exec(src) File "", line 7, in EOFError: EOF when reading a line


Ran 2 tests in 0.001s

FAILED (errors=2)

When I ran this code in workspace, it works perfectly but in the challenge window it is giving error. Can someone help in:

  1. Understandind the error and its cause
  2. Resolving the error

1 Answer

This answer from stackoverflow may help. To pass the challenge just include the suggest function.

Thanks Kris.