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

or porat
or porat
684 Points

String problem

Hey! It's ask me to wring a single argument in the function, one string. and so i did. but i get SyntaxError. what is wrong with my cod?

thanx!

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

2 Answers

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

Hi there! The thing inside the parentheses is what we call a parameter. And it's going to accept a string coming in from another piece of code. In this case, it's Treehouse that's sending in the string. And we have no idea what that string is. So it needs to accept any string we send it. Otherwise, this code bit would only ever work for the string "icecream". Imagine having to copy that code for every imaginable word!

So the parameter is essentially the declaration of a variable that will be used inside that function. When the function ends the variable will no longer be accessible.

So, I'm going to give you the first line, and we'll see if you can get the rest yourself!

def just_right(my_string):

Note that there are no quotation marks around my_string. Remember, this is a variable.

Good luck, but let me know if you're still stuck! :sparkles:

or porat
or porat
684 Points

hey Jennifer and thanx once agine! im still stuck tho, i understood my mistake but now it said that theres a problem with the "elif"

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

Hi, you are correct! There's a couple more problems here, but that was the biggest one (in my opinion). Your elif is not coded properly. It should look exactly like an if statement. This means that you should have elif a > b: for example. But your condition comes on the next line.

Also, the challenge does not ask you to print those strings. It asks you to return them. So everywhere you see print, you should replace it with return.

Give it one more shot! :sparkles:

or porat
or porat
684 Points

thanx jennifer it works! you are the best!!