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 trialAlvaro Sanmartin Cid
Python Web Development Techdegree Student 1,065 PointsProblem handling ValueError
I am trying to understand why this is wrong...but I can't see why
def suggest(product_idea):
try:
if (product_idea.len <= 3):
raise ValueError
else:
return product_idea + "inator"
except ValueError:
print ("Idea needs to be at least 3 characters long")
2 Answers
Martin Luckett
32,591 Points"product_idea.len" is not a valid way to check for the length of the string.
There are ways to do it using dot methods on strings but the len() function is generally easier.
Martin Luckett
32,591 PointsYou're welcome