Find the division remainder of a number

Bob picture Bob · Apr 7, 2011 · Viewed 601.8k times · Source

How could I go about finding the division remainder of a number in Python?

For example:
If the number is 26 and divided number is 7, then the division remainder is 5.
(since 7+7+7=21 and 26-21=5.)

Answer

Uku Loskit picture Uku Loskit · Apr 7, 2011

you are looking for the modulo operator:

a % b

for example:

26 % 7

Of course, maybe they wanted you to implement it yourself, which wouldn't be too difficult either.