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!
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
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"
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