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

Kris Reid
Kris Reid
17,133 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
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

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
17,133 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!