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

Kevin Lankford
Kevin Lankford
1,983 Points

str length counter

Here is my code for this challenge--

def just_right(word):

blah = str(word)

if len(blah) < 5:
    print("Your string is too short")

elif len(blah) > 5:
    print("Your string is too long")

else:
    return True

This works on the console but is not accepted here. I even added the extra step

of making sure the input was converted to a string. If there is anything else needed

thats relative to the video prior this this (try/exc etc) I can add it, but was not sure why

this was not working.....

strlen.py
def just_right(word):

    blah = str(word)

    if len(blah) < 5:
        print("Your string is too short")

    elif len(blah) > 5:
        print("Your string is too long")

    else:
        return True

1 Answer

Steven Parker
Steven Parker
231,269 Points

It may "work" on the console, but it's not doing what the challenge asks. But you're really close!

:point_right: The challenge asks you to return the strings, not print them.

And you didn't need that str() conversion.