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

Does not accept my code

My code seems to work but the corrector doesn't accept it.

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

2 Answers

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there! The challenge asks you to return the strings, but you're printing the strings. Try again after changing your print statements to return statements.

Hope this helps! :sparkles:

Ludovic Dumas
Ludovic Dumas
12,245 Points

Thank you I was also stuck for the same reason.

Samuel Ferree
Samuel Ferree
31,722 Points

Your code is functional, and has the right idea, but if I remember correctly, the challenge asks you to return the strings about being too short, or too long. Not print them. For example:

if len(string) < 5:
  return "Your string is too short"

Also double check casing and punctuation, not sure how picky the challenge engine is.