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

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,860 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: