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!

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

Mohsan Chaudhry
Mohsan Chaudhry
1,469 Points

Am I supposed to generate strings of variable length to test?

Not sure what I'm doing wrong. Am I supposed to generate strings of variable lengths?

Any help would be appreciated.

import random, string

def just_right(string):
        if len(string) > 5:
            print ('Your string is too long')
        elif len(string) < 5:
            print ('your string is too short')
            return True

1 Answer

Steven Parker
Steven Parker
225,664 Points

point_right: The challenge asks you to return one of three possible results.

You will not need to print anything. Just return the strings and you should pass the challenge.

Also, while it doesn't affect passing he challenge, I noticed these minor issues:

  • the indentation is not consistent, the first stop is twice as wide as the next
  • you don't need to import anything for this challenge

:point_right: You forgot to put an extra colon in front of point_right: :smile:

Just a little note