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

Benny Shtark
Benny Shtark
743 Points

i have no idea why this challenge doesnt work.. in my local setup all seems fine..

My code works just fine on my PC, but for some reason i get "Bummer! Try again!" :(

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

4 Answers

The challenge asks you to return the answer, not print it, change the print to return in both answer strings and your code will pass. :)

David Hamilton
David Hamilton
21,522 Points

Hello Benny,

You need to use "return" instead of "print":

def just_right(my_arg):
    if len(my_arg) < 5:
        return("Your string is too short")
    elif len(my_arg) > 5:
        return("Your string is too long")
    else:
        return True
Carlos Alberto Del Cueto Carrejo
Carlos Alberto Del Cueto Carrejo
13,817 Points

Hello Benny, you are printing your results to the screen with a print statement, the challenge is asking you to return them. I actually took some time myself to see what was going wrong. It happens to the best of us . Keep coding ;)

Benny Shtark
Benny Shtark
743 Points

thanx alot!!

now i understand it :D

in fact i have used this knowledge today in some work script.

cheers