Python Multiplication Assignment

Python multiplication assignment is done with *=, the multiplication assignment operator.

Example:

>>> x = 3
>>> x *= 5
>>> x
15

Read more about the Python multiplication operation

You can’t multiply and assign to an undefined variable

>>> d *= 3
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'd' is not defined

You can’t multiply and assign to a literal

>>> 3 *= 3
  File "<stdin>", line 1
SyntaxError: can't assign to literal