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 trialDavid Wright
4,437 Pointsstrlen.py - I can't figure out what is wrong with my function
I also tried a different 'else' condition, but that didn't help. It looked like:
else len(some_string) == 5:
def just_right(some_string):
if len(some_string) < 5:
print("Your string is too short")
elif len(some_string) > 5:
print("Your sting is too long")
else:
return(True)
1 Answer
Vittorio Somaschini
33,371 PointsHello David.
I noticed a couple of things you need to correct here:
1) the code challenge does not ask you to print anything, it only wants return statement. 2) in one of the strings in your function there is a little typo.
Please note that when you return a single value you don't need parenthesis, for example: return True
Vittorio
Chris Freeman
Treehouse Moderator 68,441 PointsChris Freeman
Treehouse Moderator 68,441 PointsAbout
return
. It is a keyword not a function. You don't need parens when returning multiple values either. Parens may be used to group items when they span multiple lines.Vittorio Somaschini
33,371 PointsVittorio Somaschini
33,371 PointsI am soo bad with terminology!
;) @Chris
Vittorio
David Wright
4,437 PointsDavid Wright
4,437 PointsYou aren't bad with terminology. Honestly, I liked your approach to answering my question. Chris has been a godsend during the past week when I've run into trouble, but I also like other comments by some that have been a little less direct and made me think a bit about the concepts. Chris's comments are on point, but both feedback perspectives have helped me to learn!
So, thank you @Vittorio