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 trialDeonte Meriwether
1,513 Pointsvalue 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"
2 Answers
Daniel Turato
Java Web Development Techdegree Graduate 30,124 PointsRaising 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 Newman
1,138 PointsI'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
Deonte Meriwether
1,513 PointsDeonte Meriwether
1,513 PointsOh I see now. Thank you for helping me with this one Daniel! It seems like I was so close but still so far from solving this one :)