odd even checker

does anyone know how to check a variable to see if it is odd or even, i have a variable which runs from 0 to 499 and when its odd i want one thing to happen when its even another.
it seems like a simple bit of maths but i cant figure it out.

any ideas

thankyou :smiley:

heh try this,

if num%2 == 0:
   #even number
   #odd number

Jason Lin

Well I’m not clued-up on the game engine, but I imagine a way to test odd or even status would be to divide the current value by 2. If the resultant number is a whole int value (ie has no decimal in it), then you could flag that number as even.

Have to let other more experienced programmers in here tell you how it’s done though. I haven’t the foggiest LOL

thanks guys, jasons bit of code works great :slight_smile: