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 trialRoopa Sridhar
1,174 Pointsstrlen challenge
Why is this code wrong ? def just_right(your_message): try: str(your_message) if len(your_message) < 5: return "Your string is too short" elif len(your_message) > 5: return " Your string is too long" else: return True except ValueError: return "Not a vaid string "
def just_right(your_message):
try:
str(your_message)
if len(your_message) < 5:
return "Your string is too short"
elif len(your_message) > 5:
return " Your string is too long"
else:
return True
except ValueError:
return "Not a vaid string "
2 Answers
Chase Marchione
155,055 PointsHi Roopa,
Looks like it's a minor issue: there's a space you will want to remove at the beginning of one of your return strings (that space is considered part of the value of the string.)
return "Your string is too long"
Hope this helps!
Roopa Sridhar
1,174 PointsThe extra space was exactly the issue. Thank you so much for pointing it out ! Appreciate your timely help !!