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 trialPhilip Kalinda
4,663 Pointsjust_right
struggles :( Create a new function named just_right that takes a single argument, a string. If the length of the string is less than five characters, return "Your string is too short". If the string is longer than five characters, return "Your string is too long". Otherwise, just return True.
argument=str()
def just_right(argument):
if len(argument) > 5:
print("Your string is too long")
elif len(argument) < 5:
print("Your string is too short")
else:
return True
4 Answers
Martin Cornejo Saavedra
18,132 PointsThe function must "return", not "print".
#argument = str() #this is not necessary for the challenge
def just_right(argument):
if len(argument) > 5:
return("Your string is too long")
elif len(argument) < 5:
return("Your string is too short")
else:
return True
Nilton S Bossolan
Courses Plus Student 1,047 PointsCompleted the challenged and was surprised how simple it was actually.....
Cristiano Monteiro
5,942 Pointsi managed to do the challenge but cant quite get why the function must return or why you cant use the prints.
Chris Freeman
Treehouse Moderator 68,441 PointsThe challenges are graded by a checker program that only can "see" results from a program's perspective. That is, it only sees what is returned by the function. So the checker calls the function and then evaluates the returned object for correctness.
The output of a print statement would show up on a console for human consumption but would not be seen by the checker.
Cristiano Monteiro
5,942 Pointsah okay that makes sense. Thanks
Chris Freeman
Treehouse Moderator 68,441 PointsChris Freeman
Treehouse Moderator 68,441 PointsAlso: Parens are not necessary in the return statement.
Philip Kalinda
4,663 PointsPhilip Kalinda
4,663 PointsThanks a bunch guys! really appreciate the help! Martin Cornejo Saavedra & Chris Freeman
timoleodilo
1,438 Pointstimoleodilo
1,438 Pointsdamn. u were right. thats what was holing me up. i had print instead of return