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

Yessica Schoonen
Yessica Schoonen
1,553 Points

SyntaxError at Task 1

Pretty sure I forgot something here but don't know what....

even.py
def odd_even(5):
    if number == False
        return

odd_even()

2 Answers

Kurt L
Kurt L
22,856 Points

The challenge is asking us to define a function that takes one parameter, a number (hint: integer is best). The function should then test the number that was passed in, and return True if the number is even (that is, the remainder after dividing by 2 is 0), and to return False otherwise. :)

Kurt L
Kurt L
22,856 Points

Hint: the definition should start like this:

def odd_even(number):
Christian Rowden
Christian Rowden
2,278 Points

Hello,

What this lesson is trying to teach you is %

For example, 10 % 2 == 0. This is because % will return the remainder of a division so 10 / 2 = 5.0

so 10 % 2 == 0

if you code an if statement like the following:

if arg % 2 == 0:

    return True

else:

you'll be on the right track.

Cheers and happy coding.

Yessica Schoonen
Yessica Schoonen
1,553 Points

Ahh I get it, I always end p being confused when the tasks come up. Thanks for helping out :)