Walrus Operator (Python 3.8)
Intro
Today, I would like to share a neat introduced in Python3.8 - the walrus operator. It sparked quite a bit of discussion before ultimately being accepted. 🤔️
The power of the walrus operator lies in turning an assignment statement into an assignment expression. You may be wondering: what exactly is the difference between a statement and an expression?
Expression vs Statement
In programming languages, you may encounter many different constructs. Broadly, they can be divided into two categories - expressions and statements. An expression is evaluated and produces a value, whereas a statement performs an action and does not return anything.