Python Bitwise Shift Left Assignment

Python bitwise shift left assignment is done with <<=, the bitwise shift left assignment operator

Example:

>>> x = 5
>>> x <<= 3
>>> x
40

Read more about the bitwise shift right operator

You can’t bitwise shift left 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 bitwise shift left and assign to a literal

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