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

This one should be short and sweet. Write a function named even_odd that takes a single argument, a number.

am a little struck

even.py
def even_odd(number):
    if number == 8 % 2:
        return True
    else:
        return False

1 Answer

Hey, so your syntax for the function is correct.

However, the logic needs a little tweaking. In programming, there's a very simple and basic way to evaluate if a given number is even or odd.

If you use modulo division with an even number and 2, the answer should be 0. Conversely, if you were to perform modulo division using an odd number with 2, you get 1 as an answer.

So all you need to do is change the condition in the if statement accordingly so that 'True' is returned when you pass a number parameter and performing modulo division on it with 2 equals to 0.

Hope that helped!

am still a little stuck