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

Nicolas Curat
Nicolas Curat
2,995 Points

Why isn't my code working

I don't understand what is the problem in my code. I've tried it by my own and it works just fine but the challenge is not accepting it. Please help!

strlen.py
def just_right(text):
    if len(text) < 5:
        print("Your string is too short")
    elif len(text) > 5:
        print("Your string is too long")
    else:
        return True

2 Answers

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there! I believe it's simply a misunderstanding of the instructions. The challenge asks you to return the strings, but you are printing the strings. Try returning the strings instead.

Hope this helps! :sparkles:

Nicolas Curat
Nicolas Curat
2,995 Points

Thank you! You were right, I had to return them instead of printing them.

damn! I tried for hours now and completely went insane about that...

and now it works. thanks for the hint and perhaps you could fine tune the instructions a little bit :D

Jennifer Nordell
seal-mask
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

To be clear, I am not Treehouse staff. I'm a student just like yourself. That being said, the instructions do explicitly state to return the strings. If you can think of better wording, you might send a suggestion to help@teamtreehouse.com. It has been my experience that they love to get feedback from students. :sparkles: