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 trialStoyko Stoyanov
4,445 PointsScript runs ok in PyCharm, however throws 2 errors on treehouse
Hi, Regarding the Rase an Exception challenge, here is what i have done that works 100% in PyCharm:
def suggest(product_idea):
if len(product_idea)<3:
raise ValueError("Needs to be more than 3 chars")
return product_idea + "inator"
product_idea=input("add brand new product names: ")
try:
print(suggest(product_idea))
except ValueError as a:
print("Not a valid input!",a)
However when i enter the code into treehouse I get these 2 errors:
RROR: 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 6, 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 6, in EOFError: EOF when reading a line
Any help,please?
1 Answer
Steven Parker
231,886 PointsThe extra stuff you added to run externally isn't needed (and causes trouble) in the challenge.
For the challenge, you only need to modify the function. You won't need any code after the function, and in particular you won't need a "try", "except", or to "print" anything.