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 trialPovilas Jurgaitis
6,792 PointsCan't pass string length objective
Please help me what I do wrong. My code:
def just_right(str): if len(str) < 5: print('Your string is too short') elif len(str) > 5: print('Your string is too long') else: return True
def just_right(str):
if len(str) < 5:
print('Your string is too short')
elif len(str) > 5:
print('Your string is too long')
else:
return True
Believe It Or Dot
3,640 PointsSo, yeah, how many have been stuck in this technicality? I know I spent 15 minutes til I reached this "forum".
1 Answer
Stephen Gheysens
11,935 PointsHi Povilas! This is pretty subtle, but it looks like the challenge is asking for you to return the strings "Your string is too short" or "Your string is too long", rather than just printing them. In your case, the only time there is a return value from this function is when the string is exactly 5 characters long.
Povilas Jurgaitis
6,792 PointsThank you very much. I returned a string with text and it was it.
Nathan Tallack
22,160 PointsNathan Tallack
22,160 PointsWoah. That's trippy. Your code looks good to me. Will be interesting to see what was wrong.