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

wesley jackson
wesley jackson
2,436 Points

strlen.py

Hi, My code works correctly in isolation but not passing. I would appreciate any pointers as to where I am going wrong. Thank you

strlen.py
def just_right(str):
    num =int(str)
    if  num < 5:
        return("your string is too short")
    elif num > 5:
        return("Yor string is too long")
    else:
        return True

1 Answer

Hi wesley jackson,

To get the length we use len(str). With int(str) we convert a string to an integer. For the rest, you need to literally return the text which they asked for. The rest is good though.

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

I hope this helped!


sig

wesley jackson
wesley jackson
2,436 Points

Thank you First, truly appreciate your answer and swift response.