Is there a modulo function in the Python math library?
Isn't 15 % 4, 3? But 15 mod 4 is 1, right?
Is there a modulo function in the Python math library?
Isn't 15 % 4, 3? But 15 mod 4 is 1, right?
mod = a % b
This stores the result of a mod b in the variable mod.
And you are right, 15 mod 4 is 3, which is exactly what python returns:
>>> 15 % 4
3
a %= b is also valid.