Hello there. I think I was given inaccurate answers.
I know that
:= does not work in Python 3.7!
My question dealt with a new Python feature.
Python 3.8, released in October of this year introduced :=
Please read from "What's New":
Summary – Release highlights
New Features
Assignment expressions
There is new syntax := that assigns values to variables as part of a larger expression. It is affectionately known as “the walrus operator” due to its resemblance to the eyes and tusks of a walrus.
In this example, the assignment expression helps avoid calling len() twice:
if (n := len(a)) > 10:
print(f"List is too long ({n} elements, expected <= 10)")
...
I know that
:= does not work in Python 3.7!
My question dealt with a new Python feature.
Python 3.8, released in October of this year introduced :=
Please read from "What's New":
Summary – Release highlights
New Features
Assignment expressions
There is new syntax := that assigns values to variables as part of a larger expression. It is affectionately known as “the walrus operator” due to its resemblance to the eyes and tusks of a walrus.
In this example, the assignment expression helps avoid calling len() twice:
if (n := len(a)) > 10:
print(f"List is too long ({n} elements, expected <= 10)")
...