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 Even or Odd

how would i declare the number in this script

It wants a number for the function even_odd but every time i put a number in it, it says syntaxerror

even.py
def even_odd(5):
    if even_odd() % 2:
        return True
    else:
        return False

2 Answers

James J. McCombie
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
James J. McCombie
Python Web Development Techdegree Graduate 21,199 Points

You have the number 5 inside the (), you need to put a parameter like x, or you could use a keyword argument like x=5, this would mean if you called the function with no inputs it would set x=5 as the default.

you still need to do something with the x in the function however.

In you function you are calling the function again, if it were not for the syntax error I think you would also hit a recursion error. If you did define the parameters for the function as I described above it would keep calling itself to no end.

you are also not checking if the number is even or odd.

the if keyword needs the statement after it to evaluate to true or false, which yours will since you get a truthy value back, but to check if even you need to do:

<number> % 2 == 0

First you need to replace the argument in the parentheses with a variable name, like number. Then you need to perform modulo against it. If the modulo evaluates to 0, then it's even.

i got past the syntax error but now it is not returning the correct answer