Python Floor Division Assignment

Python floor division assignment is done with //=, the floor division assignment operator.

Example:

>>> x = 18
>>> x //= 5
>>> x
3

Read more about the Python floor division operation

You can’t floor divide 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 floor divide and assign to a literal

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