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 trialHimanshu Patil
448 PointsRaise error
what is wrong with my code
def suggest(product_idea):
return product_idea + "inator"
if len(product_idea) < 3:
raise ValueError("Need more that 3 chars")
4 Answers
Jeff Muday
Treehouse Moderator 28,722 PointsYour code is correct, but just a little out of order. The "if" statement needs to test the length of the product_idea and raise an error before we return the product_idea + "inator"
see below
def suggest(product_idea):
if len(product_idea) < 3:
raise ValueError("Need more that 3 chars")
return product_idea + "inator"
Good luck with your Python journey!
Himanshu Patil
448 PointsThank you for your quick response.
Nurtilek Taalaibekov
387 PointsHi there, Jeff I am stuck on code challenge on "Python basics ", raising an exception I did everything like you said but still got an error. ! Imgur
Daron Anderson
2,567 Points@Nurtilek Taalaibekov, Your if statement needs to be aligned with your return statement. its an indentation error.
Daron Anderson
2,567 PointsThis little section was the highlight of my day.
Jeff Muday
Treehouse Moderator 28,722 Points@Nurtilek Taalaibekov -- what is the error message you are getting?
Daron Anderson
2,567 PointsDaron Anderson
2,567 PointsYour brain is really sharp, I didnt know to use len, saw your code and was like oh theres my answer and instantly I knew your return should have been at the bottom of the raise aligned with the if. Two brains are always better than one. Thanks man. Great Job! dont get discouraged your built for this.