Operators
%= — Remainder assignment
Update a number with its remainder, or a string or bytes object with percent-style formatting. For integer operands a nonzero remainder has the divisor’s sign. Formatting immutable strings replaces the binding rather than changing the original string. The __imod__() hook may modify its receiver or supply a replacement. If absent or declining with NotImplemented, normal binary dispatch applies. The result is stored back into the target; this is a statement, not an expression. A failed store does not guarantee rollback.
Formal Syntax & Structure
python syntaxpython
target %= expressionParameters & Attributes
| Name | Type | Description |
|---|---|---|
| target | object | Existing assignable name, attribute, item or slice; its current value participates in the operation. |
| right | nonzero divisor or formatting arguments | Value used as the right operand of the operation. |
Working Example
Example Snippetpython
minutes = 137minutes %= 60label = "count=%03d"label %= 7print(minutes)print(label)