Welcome to the Treehouse Community
Looking to learn something new?
Deonte Meriwether1,513 Points
value error format
Im having trouble raising value errors and creating the condition when I need to calculate the number of characters inpu
def suggest(product_idea): if len(product_idea) < 3 raise ValueError("Too short try again") return product_idea + "inator"
Daniel TuratoJava Web Development Techdegree Graduate 30,124 Points
Raising the error should be on it's own separate line like so:
def suggest(product_idea): if len(product_idea) < 3: raise ValueError("Too short try again") return product_idea + "inator"
Zach Newman1,138 Points
I'm having trouble on this one as well with the formatting and applying what I need following the example set by daniel, when I run it I get this:
ERROR: test_exception_not_raised (main.TestRaiseExecution)
Traceback (most recent call last): File "", line 24, in test_exception_not_raised File "", line 3, in suggest ValueError: Too Short, try again.
FAIL: test_exception_raised (main.TestRaiseExecution)
Traceback (most recent call last): File "", line 32, in test_exception_raised AssertionError: ValueError not raised : I passed in 'a' and expected a ValueError to be raised
Ran 2 tests in 0.000s
FAILED (failures=1, errors=1)
I'm not quite where I'm going wrong