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 Python Basics Functions and Looping Raise an Exception

I cant get past this question. Please explain what i'm doing wrong or at least provide a solution i can compare to?

The scrip dose its job, but isn't passing the question. Why????

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 20, 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 20, in execute_source exec(src) File "", line 7, in

EOFError: EOF when reading a line

Ran 2 tests in 0.002s FAILED (errors=2)

suggestinator.py
def suggest(product_idea):
    if len(product_idea) < 3:
        raise ValueError("that suggestion will not work.")
    return product_idea + "inator"

try:
    product_idea = input('what is your suggestion? ')
    new_name = suggest(product_idea)
except ValueError as err:
        print('must be greater then three letters.')
        print('{}'.format(err))
else:
              print(new_name)

2 Answers

Steven Parker
Steven Parker
228,978 Points

It looks like you did a good bit of things not asked for in the instructions. In particular, you won't need any "try" or "except", and you won't need to "input" or "print" anything.

Your task is only to modify the function, you won't need to call it yourself.

Thank you for the fast response! You were correct. I submitted the function and it passed. looking at it now can see that I did well more then needed. Tho it did cement the thought path covered in this section!