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 Sinks
Wesley Sinks
15,290 Points

What am I missing here??

Am I missing a step somehow on this one?

strlen.py
def just_right(i):
  if len(i) < 5:
    print("Your string is too short")
  elif len(i) > 5:
    print("Your string is too long")
  else:
    return True
Wesley Sinks
Wesley Sinks
15,290 Points

Sorry, I see the challenge details weren't included.

I'm supposed to define a function that takes one string as an argument, prints some text if it's less than 5 chars long and different text if more than 5 chars. Lastly, return True if the length is "just right"

1 Answer

Wesley Sinks
Wesley Sinks
15,290 Points

I see I was supposed to return the strings, not print them. All good!