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

I don't understand why my code doesn't work

I'm getting either the error that says that it didn't give the right answer or it takes 0 positional arguments but one was given and I don't know how to fix it.

strlen.py
def just_right(word):
    word=[]
    if len(word) > 5:
        return("Your string is too long")
    elif len(word) < 5:
        return("Your string is too short")
    else:
        True

1 Answer

Jason Anders
MOD
Jason Anders
Treehouse Moderator 145,858 Points

Hi Molly,

You've pretty much got it... just two small things:

  1. The method takes a string as a argument, but for some reason you are taking that string being passed in and re-assigning it an empty dictionary? I'm not sure where you got that from, so line 2 just needs to be deleted.
  2. In your else clause, you are missing the return keyword needed to return True.

Once those two things are taken care off, the rest of the code looks great and will pass! :thumbsup:

Keep Coding! :) :dizzy: