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

Not sure what the issue is here my code seems to work just fine in a python interpreter

def just_right(somestr): if len(somestr) < 4: print("Your string is too short") elif len(somestr) > 4: print("Your string is too long") else: True

I am not sure why the quiz is not accepting this as my answer. It has the desired behavior when I use my interpreter to test.

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

2 Answers

Steven Parker
Steven Parker
229,982 Points

Just because code runs, it doesn't prove that it is doing the right thing.

:point_right: The Challenge asks you to return the strings, not print them.

You also need to return True when the length is right.

Thanks Steven !, that was exactly what I was doing wrong.