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 trialMint Milano
3,114 Pointscould not get the simple program right..where do you think i have made a mistake..?
did i miss something?
def just_right(str):
if len(str)<=5:
print ("Your string is too short")
return True
2 Answers
Amir Eskandari
9,153 PointsHey there,
You are very close. Read the question very carefully and try something like this:
def just_right(str):
if len(str) < 5:
return something
elif len(str) > 5:
return something
else:
return something
Let me know if you have more questions.
Alexander Davison
65,469 PointsFor this challenge, the Code challenge wants you to do more than one if
/elif
/else
.
The challenge wants you to be able to return either "Your string is too short", "Your string is too long", or True, not only "Your string is too short".
Also, you should be printing anything, but returning
the string (if the string is greater than or less than 5).
Lastly, I should point out that <=
and >=
mean "less than or greater to" and "greater than or equal to", so if the length is five, it would go inside that if
which is wrong. Instead use >
and <
.
If you hook those other messages up, you should end up with:
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
Good luck! ~alex
Mint Milano
3,114 PointsThank you alex.
Mint Milano
3,114 PointsMint Milano
3,114 PointsThank you! yea sure! cool!