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

Chase Alfrey
Chase Alfrey
996 Points

Strlen.py python lesson problem

It's telling me to have it detect the length of the string and say if it's too big or too small, but it just won't work for some reason. Can somebody help me?

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

1 Answer

Stuart Wright
Stuart Wright
41,120 Points

All of the logic in your code is correct, you just need to fix one of your strings:

"Your number is too long"

should be:

"Your string is too long"

It's always the simple things... :)

Chase Alfrey
Chase Alfrey
996 Points

I can’t believe I missed that! I was making a number game earlier, so I must’ve got used to typing number instead of word.