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 trialChristopher Borchardt
2,908 PointsCan't complete challenge
I am attempting to do the string length challenge task. When I submit my code it says "Bummer! Try again!" but it doesn't give me an idea of where to look for the error. I've gone over my code and I just can't see what I have wrong, can somebody give me a hint of what line I should be looking at?
def just_right(string):
if len(string) <5:
print("Your string is too short")
elif len(string) >5:
print("Your string is too long")
else:
return True
2 Answers
Jennifer Nordell
Treehouse TeacherActually, it's supposed to return anything it gets as a result... not print. While the exercises up to this point probably had you print the result, it's specifically stated in the challenge to return the result. Try this out:
def just_right(string):
if len(string) <5:
return "Your string is too short"
elif len(string) >5:
return "Your string is too long"
else:
return True
Christopher Borchardt
2,908 Pointsthank you, miss one thing in the directions :)
Jennifer Nordell
Treehouse TeacherYup! Like i've said so many times... it's generally not the gigantic logic flaws that'll get you. It's the missed quotation mark or some other silly something!
Leen Leenaerts
Courses Plus Student 2,367 PointsLeen Leenaerts
Courses Plus Student 2,367 Pointscan you describe the exercise? should it return something (e.g. False) when it's not equal to 5?