Account
Categories

Modulus AND Assign Operator


Definition:

The Modulus AND Assign Operator (%=) is used to divide a variable by a value and store the remainder in the same variable.

It divides the value on the left side by the value on the right side and saves the remainder.

Syntax:

variable %= value

Example:

x = 17
x %= 3  # remainder of x divided by 3
print(x)

Output: