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 trialRyan Jaccard
2,504 PointsMy Code Works in the Workspace REPL, But Not When I "Check Work" in Code Challenge
This script runs error-free in the Workspace REPL, but the "check work" button keeps giving me errors. Any ideas?
def suggest(product_idea):
if len(product_idea) < 3:
raise ValueError("That's too short")
return product_idea + "inator"
try:
product_idea = input("What's the name of your product?")
result = suggest(product_idea)
except ValueError as err:
print("Oh no")
print(err)
else:
print(result)
See below for the error message I'm receiving when I test the code directly within the Code Challenge. I don't understand why it's referencing lines that don't exist in my script (ex. line 23, 24, 30), and it makes mention of file path "/workdir/utils/challenge.py", even though this Code Challenge file is called "suggestinator.py"....
I've tried refreshing my browser and running everything in a Private chrome tab, but still keep running into the error. I'm sure I'm overlooking something in the code. Thanks in advance for your help, everyone!
Task #1
.
Ran 1 test in 0.000s
OK
EE
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)
1 Answer
<noob />
17,062 PointsHello!, your solution is correct good job! u just need to delete this code:
try:
product_idea = input("What's the name of your product?")
result = suggest(product_idea)
except ValueError as err:
print("Oh no")
print(err)
else:
print(result)
because u were not being asked to do this checkes.
Ryan Jaccard
2,504 PointsRyan Jaccard
2,504 Pointsthank you bot .net !