Welcome to the Treehouse Community
Looking to learn something new?
Script 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:
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: ")
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
Steven Parker220,937 Points
The 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.