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

Thomas Aarts
Thomas Aarts
970 Points

what am I missing on my strlen script?

I'm not sure what I am missing within my script. I wrote a similar script in my external workspace and it worked.

def just_right(): string = str(input("Enter a string: ")) if len(string) < 5: print("You're string is too short") elif len(string) > 5: print("You're string is too long") else: return True just_right()

strlen.py
def just_right(string):
    if len(string) < 5:
        print("You're string is too short")
    elif len(string) > 5:
        print("You're string is too long")
    else:
        return True

4 Answers

A little thing:

The challenge never asked you to print anything. You have to return the messages :)

I think you can make out what's wrong with this hint. ;)

~Alex

Need more hints? Please ask below :smile:

Jason Anders
MOD
Jason Anders
Treehouse Moderator 145,860 Points

In addition to Alexander, you also have a small typo. Not so much a spelling error, but you are using "You're" (you are), when it should be "Your". This error will also cause a Bummer!

:) :dizzy:

Oh I didn't notice that :)

Thanks for letting me know! :smile:

The question never asked you to print, it asked you to return.

Thomas Aarts
Thomas Aarts
970 Points

thanks. It looks like I was doing too much and took out the input and print functions and it worked. Thanks for all your suggestions!