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

George Lugo
seal-mask
.a{fill-rule:evenodd;}techdegree
George Lugo
Python Web Development Techdegree Student 922 Points

what am i doing wrong for this problem

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

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

1 Answer

Just a couple minor problems mainly causing Syntax Errors.


  1. You can't use quotes for parameter names. Python will cause a Syntax Error because it isn't a valid variable name.
  2. You have periods at the end of some of the statements and Python will cause a Syntax Error if you have periods.
  3. You shouldn't print anything; wherever you are printing things, you should return it.

I hope this helps. ~Alex


If you continue to fail, please respond. Also, if your question is answered, please post below & provide a best answer so that this question gets a "Check mark" next to this question in the Community.