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

Daniel McFarlin
Daniel McFarlin
5,168 Points

I'm having troubles understanding the questions here. Haven't used the % much so I am not quite sure

Hey everyone! Don't mean to ask so many questions, but I keep finding myself stumped on some of these code challenges. Anyways I haven't really used the "%" much and so I am not sure how to apply it to this question. I know it deals with division with a remainder, but I don't understand how to use it specifically in this coding problem. Any help y'all can provide would be much appreciated! Thank you! :)

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

3 Answers

You use is to compare if something is None, so don't use it here.

A number is even when it's remainder after devision with 2 equals to 0. This translates to: if num%2==0 then return true else false

You can use x % 2 == 0 to determine if x is odd. Keep in mind that % is basically calculating the remainder of x divided by 2!

Also, the challenge didn't ask you to edit this function.

:warning: Don't edit the function!!

The result of % 2 should be zero if even and one if odd. You should include that in a conditional if then statement.

If zero results from %2 then it is even. Etc