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

My strlen.py function is not working, why?

I created a file on my machine and did the exercise locally. This code seems to work as required by the description of the challenge (Task 1 of 1) . But the system is not passing it. What am I missing?

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

2 Answers

Stuart Wright
Stuart Wright
41,119 Points

You need to change your two print statements to returns instead. That will make your function pass the challenge.

I was in a hurry and did not read the challenge correctly. In the exercises before we just printed it, but the challenge clearly states return.

Thanks