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!

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

Hint about even.py remainders

It says in the even.py challenge task that we have to return true or false. I am sure it wants me to use the random.randint in the library to generate the number but I am having trouble with how to write the code that would determine if there is a remainder or not so I can put in the if/else part.

1 Answer

They have added the hint in the challenge. % (mod) gives you the remainder. E.g. 4%2=0 and 5%2=1

Hope this helps.

def evenOdd(num):
      return not num%2