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 trialRina Schwartz
1,672 PointsI can't figure out how to fix my error handling code.
I can't figure out how to fix my error handling code. I think I know what the problem is, but I've no idea how to fix it
def suggest(product_idea):
if product_idea < 3:
raise ValueError("You must use 3 or more characters.")
return product_idea + "inator"
except ValueError as err:
3 Answers
Mark Sebeck
Treehouse Moderator 37,799 PointsHi Rina. I have a confession. I didn't remember how to determine the length of a string in Python either. So I googled it and found this
# Length of below string is 5
string = "geeks"
print(len(string))
so i think you just need to call len(product_idea) in your if statement and it should work.
Keep at it and don't be afraid to google something you don't know. Everyone does.
Mark Sebeck
Treehouse Moderator 37,799 PointsAlso delete your last line
except ValueError as err:
That line is not needed
Rina Schwartz
1,672 PointsThank you! I will try this!
Rina Schwartz
1,672 PointsIt worked! Thank you!
Rina Schwartz
1,672 PointsRina Schwartz
1,672 PointsHow can this be a value error when the text is a string? I guess I can count the number of letters, but I don't know how to do that. Did we do that? and I don't know what the "inator" is, so I was afraid to remove it.