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 trial

Python Python Basics (2015) Number Game App String length

strlen.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:

strlen.py
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
Vittorio Somaschini
33,371 Points

Hello 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
Chris Freeman
Treehouse Moderator 68,426 Points

About 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
Vittorio Somaschini
33,371 Points

I am soo bad with terminology!

;) @Chris

Vittorio

You 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