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

Paul West
Paul West
6,925 Points

Quiz will not pass.

I have written this two way one with a try/exception block and one without. tested both in workspaces and the code works. however the quiz will not let me pass.

with try/exception:

strlen.py
def just_right(arg1):
  try:
    if len(arg1) < 5:
      print("Your string is too short")
    elif len(arg1) > 5:
      print("Your string is too long")
    else:
      return True
  except TypeError:
    return False

2 Answers

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Your code is fine! But the devil is in the details, and you didn't follow their instructions to the letter. I know, I know... challenges are super picky! The challenge explicitly states to return the strings... not print them. If you change the two print words in your code to return, your code passes! Hope this helps! :smiley:

Paul West
Paul West
6,925 Points

Jennifer, thank you. I sometimes think I am working through a game of gotcha with this course's quizzes. I must have read those instructions 20 times and didn't catch the return part

Jennifer Nordell
seal-mask
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Paul West If it helps... you're not the only one! Sometimes I've had to stop myself and go grab a cup of tea or coffee or something. Then I come back and force myself to read it word for word. Because I have in my mind a pretty clear idea of what they've asked me to do. But, as it so happens, when I get stuck like that it turns out that what I think they said and what they actually said are two different things :smile: :dizzy: