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

just_right not quite right

Challenge code Gods are telling me this is not returning the correct answer, but I can't figure out why.

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

2 Answers

Rich Zimmerman
Rich Zimmerman
24,063 Points

Looks like it's just a matter of having the same string for both conditions: "Your string is too short."

My goodness, thank you!

Gustavo Winter
PLUS
Gustavo Winter
Courses Plus Student 27,382 Points

Hi, the problem is you repeat the same setence for the two condition.

Check this, you will find the answer:

def just_right(test):
    if len(test) < 5:
        return "Your string is too short"
    elif len(test) > 5:
        return "Your string is too long"
    else:
        return True

My goodness, thank you!