The modulo in Python is confusing.
In Python, % operator is calculating the remainder:
>>> 9 % 5
4
However:>
Think about it like this:
0 % 5 is 0
1 % 5 is 1
So... what if you go backwards?
-1 % 5 must be 4
-2 % 5 must be 3
and so on.
You'll see that following this -9 % 5 is 1
NOTE: Depending on the programming language and the implementation of %, you might get different results since programmers disagree on how to handle negative numbers in %