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 trialJohn Leonard
1,398 Pointsjust_right function seems fine to me but it is marked wrong. If anyone can see what is wrong I would appreciate it.
Feedback just says 'Bummer! Try again'
3 Answers
Sergey Podgornyy
20,660 PointsTry this code:
def just_right( word ):
if len( word ) < 5:
return "Your string is too short"
elif len( word ) > 5:
return "Your string is too long"
else:
return True
Also notice, for markdown code, use backticks
Chris Freeman
Treehouse Moderator 68,441 PointsBased on your code, you need to use return
instead of print
def just_right(word):
if len(word) < 5:
return "Your string is too short"
elif len(word) >5:
return "Your string is too long"
else:
return True
John Leonard
1,398 PointsHi Chris, sorry to waste your time. I had to retype the code again to paste it in and in my haste typed return instead of print! My original code was
def just_right(word):
if len(word) < 5:
print("Your string is too short")
elif len(word) >5:
print("Your string is too long")
else:
return True
This also gets marked 'Bummer'
Chris Freeman
Treehouse Moderator 68,441 PointsReplace all prints
with returns
Sergey Podgornyy
20,660 PointsPlease, post code with your function here. We can't see your code in a challenge.
John Leonard
1,398 PointsThanks for the prompt reply. I ticked a box which, I think' said include code with post but anyway my code is
'''python def just_right(word): if len(word) < 5: print("Your string is too short") elif len(word) >5: print("Your string is too long") else: return True
I'd appreciate any help you can offer.
Chris Freeman
Treehouse Moderator 68,441 PointsSergey, Thanks for your help in the forum. I would like to suggest that it's better to ask for clarification and code posts as a comment to the original post instead of as an Answer. That way others can see if the question still needs attention.
Sergey Podgornyy
20,660 PointsOk, thank you Chris for your suggestion. I will do this next time ;)
John Leonard
1,398 PointsJohn Leonard
1,398 PointsThank you both for that help. I have replaced all prints with returns and it is correct. John