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

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:

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
Steven Parker
220,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.