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

Christopher Borchardt
Christopher Borchardt
2,908 Points

Can't complete challenge

I am attempting to do the string length challenge task. When I submit my code it says "Bummer! Try again!" but it doesn't give me an idea of where to look for the error. I've gone over my code and I just can't see what I have wrong, can somebody give me a hint of what line I should be looking at?

strlen.py
def just_right(string):
    if len(string) <5:
        print("Your string is too short")
    elif len(string) >5:
        print("Your string is too long")
    else:
        return True
Leen Leenaerts
Leen Leenaerts
Courses Plus Student 2,367 Points

can you describe the exercise? should it return something (e.g. False) when it's not equal to 5?

2 Answers

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Actually, it's supposed to return anything it gets as a result... not print. While the exercises up to this point probably had you print the result, it's specifically stated in the challenge to return the result. Try this out:

def just_right(string):
    if len(string) <5:
        return "Your string is too short"
    elif len(string) >5:
        return "Your string is too long"
    else:
        return True
Christopher Borchardt
Christopher Borchardt
2,908 Points

thank you, miss one thing in the directions :)

Jennifer Nordell
seal-mask
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Yup! Like i've said so many times... it's generally not the gigantic logic flaws that'll get you. It's the missed quotation mark or some other silly something!