Python Python Basics (2015) Number Game App String length

Kris Reid
Kris Reid
13,947 Points

Just_Right just not working!

I'm not sure why this isn't working! I'm following previous code examples. Perhams my logic is wrong? Can someone help me. It just says "Bummer: Try again" - Not very helpful!

Thanks! :)

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

1 Answer

Jennifer Nordell
STAFF
Jennifer Nordell
Treehouse Staff

Hi there! You're doing great, but there's a bit of a misunderstanding of the instructions here. The challenge asks you to return those strings, but you're printing the strings. Just as the else clause has a return statement, so should your if and elif. When Treehouse is running your code, it's expecting to get back a response, but the only thing sending back a response is the else.

Hope this helps! :sparkles:

Also, you will not need the string = []. This declares an empty list that is overwriting what they are sending in.

Kris Reid
Kris Reid
13,947 Points

Perfect thanks!

I wasn't aware that you could return a message with return thought it always had to be print. I'll have to investigate further!