Operators

*= — Multiplication assignment

Scale a number or repeat a supported sequence. List repetition updates the same outer list and duplicates references, not nested objects. For mutable sequences, a nonpositive integer repetition count clears the sequence. The __imul__() 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 *= expression

Parameters & Attributes

NameTypeDescription
targetobjectExisting assignable name, attribute, item or slice; its current value participates in the operation.
rightnumber or integer-like repeat countValue used as the right operand of the operation.

Working Example

Example Snippetpython
price = 8price *= 3rows = [[]]alias = rowsrows *= 2rows[0].append(5)print(price)print(alias)
Python Reference