Martin McBride
Mar 18, 2023

--

The reason for the walrus operator in Python is that a variable assigment in Python is a statement.

In many other languages, a variable assignment is an expression, so it can appear as part of a larger statement.

In C, Java etc you can do a = b = 1, but in Python that is illegal. But you can use the walrus operator to do something similar.

--

--

Martin McBride
Martin McBride

No responses yet