DRM Development 25th Anniversary

Category: Python 3

What’s New In Python 3.8 – Assignment expressions

What’s New In Python 3.8 – Assignment expressions Python Developer and Training

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 […]

Translate »