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 trialStefan Vaziri
17,453 PointsUnsure of how to do this...
I think I got the if statements right but I don't think I got the return True statement in the right place or format.
def just_right(string):
if len(string) > 5:
print("Your string is too short.")
if len(string) < 5:
print("Your string is too long.")
else:
return True
3 Answers
Adam Young
15,791 PointsIn this challenge you're expected to return
the string, not print()
it. Tricky wording :)
Also, double-check the comparison operators in your if statements and you should be all set.
Stefan Vaziri
17,453 PointsSo I updated it but I'm still getting the wrong answer:
def just_right(characters): if len(characters) > 5: return "Your string is too short." elif len(characters) < 5: return "Your string is too long." else: return True
I'm trying to figure out what I'm doing wrong with the comparison operators but not sure how to fix it.
Stefan Vaziri
17,453 PointsNvm I figured it out!
It's: def just_right(words): if len(words) < 5: return "Your string is too short." elif len(words) > 5: return "Your string is too long." else: return True
Thanks for your help Adam!