Here's the snippet that I'm trying in the Python3 interpreter,
>>> x = y = 3
>>> x, y
(3, 3)
>>> x = y = 3
>>> x, y
(3, 3)
>>> x = y = y + 3
>>> x, y
(6, 6)
>>> x = y += 3
File "<stdin>", line 1
x = y += 3
^
SyntaxError: invalid syntax
I know that SyntaxError arises when the Python grammar doesn't support the expression, but I'm not able to figure out why exactly +=
can't be chained like =
.