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

barany mok
barany mok
520 Points

My code is running good, but it doesn't pass your check, so what can I do now

My code is running good, but it doesn't pass your check, so what can I do now

strlen.py
def just_right(abc):
    abc_length = len(str(abc))
    if abc_length < 5:
        print('Your string {} is too short'.format(abc))
    elif abc_length == 5:
        return (True)
    else:
        print('Your string {} is too long'.format(abc))

1 Answer

Antonio De Rose
Antonio De Rose
20,884 Points
#nothing wrong with the way you have coded, nor the logic
#see, first of all these questions are tailor made, and look for exactly what is been asked

def just_right(abc):
    abc_length = len(str(abc))
    if abc_length < 5:
        print('Your string {} is too short'.format(abc))#you have been asked to return not to print, 
#and you have been asked to only return 'Your string is too  short'
    elif abc_length == 5:
        return (True)
    else:
        print('Your string {} is too long'.format(abc))#you have been asked to return and not to print, 
#and you have been asked to only return 'Your string is too long'