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 trialAngel Miranda
2,434 Pointsits telling me that ValueError isn't raised
product_idea = 3
def suggest(product_idea):
if product_idea != 3:
raise ValueError("add more letters")
return product_idea + "inator"
print(format(suggest))
1 Answer
Steven Parker
231,268 PointsThe instruction say to "raise
a ValueErro
r if the product_idea is less than 3 characters long". There's a few issues here:
- the length of the string should be tested, not the string itself
- the test should check for less than 3 instead of not equal to 3
- you don't need to add any code outside the function
- you don't need to
print
anything
Angel Miranda
2,434 PointsAngel Miranda
2,434 PointsI changed product_idea = 3 to product_idea = Len("abc"), != to < , and deleted everything after return but now its throwing this error: File "", line 4, in suggest TypeError: '<' not supported between instances of 'str' and 'int'
Steven Parker
231,268 PointsSteven Parker
231,268 PointsA couple more hints: