Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Python Python Basics (2015) Number Game App String length

the code is working in workspaces as is asked in question but in code challenge it's saying try again

the code is working in workspaces as is asked in question but in code challenge it's saying try again

strlen.py
def just_right(str):

    if len(str) < 5:
        print("Your string is too short")
    elif len(str) > 5:
        print("Your string is too long")
    else:
        print("True")
just_right("shubh")

1 Answer

Jason Anders
MOD
Jason Anders
Treehouse Moderator 145,624 Points

Hi shubham Sharma

Your syntax is correct, which is why the code works in Workspaces, but it is not correct to what the challenge is asking for. Instructions for challenges are very specific and very picky. They must be followed exactly or the Code Checker will return a Bummer!.

Here, there are two issues:

  1. The instructions say to use return, but you are printing.
  2. The instructions say for the final clause to return the Boolean True but you have the String "True". Remember, once you put quotes around it, it becomes a string.

Just fix those two things up and the Challenge will pass.

Nice work! :) :dizzy: