I'm sure this is painfully obvious, but forgive me for asking. I know that the modulo operator (%) returns the remainder of a divison so that for example 10 % 3 would be 1 because 3 * 3 = 9, leaving 1 ...
Why -1 % 5 Is 4 in Python (But -1 in C/Java) We all learn that % means “remainder”. But here’s something interesting: In Python: -1 % 5 Result: 4 In C, C++, or Java: -1 Same math. Different answers.