Python Python Basics (2015) Number Game App String length

Andrew Helton
Andrew Helton
4,681 Points

Works in Python Shell, but not accepted in Code Challenge. Any ideas why?

I'm just needing to understand why my code isn't being accepted as a good answer. I've tested it out in Workspaces and it works perfectly fine.

Having said that, I am tired so maybe I'm missing a typo or something...

P.S. I've tried submitting with and without the defined variable and function call. Neither answers are accepted and no hints are given as to why my answer is wrong.

strlen.py
my_string = "Hi"

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

just_right(my_string)

2 Answers

William Li
PRO
William Li
Pro Student 26,796 Points

Your code is mostly correct. But you need to change the TWO print statement into return to pass the challenge.

Andrew Helton
Andrew Helton
4,681 Points

Thanks, William. I didn't key in on the word 'return' in the problem. Appreciate the help!