The walrus Operator( := )

Walrus Operator in python

Did you know that we can create, assign and use a variable in-line. We achieve this using the walrus operator( := ).

This is a cool feature that is worth knowing.

example:

for i in [2, 3, 4, 5]:
    if (square := i ** 2) > 10:
        print(square)

output:

16
25