Question #947

What Python version introduced the walrus operator?

Python 3.8 introduced assignment expressions, written with a new operator := . This operator is also known as the walrus operator as it resembles the eyes and tusks of a walrus on its side. Assignment expressions allow to assign and use an object in one line.


print(walrus := True)
True

(realpython.com/lessons/assignment-expressions)


Comment on Disqus:

Question difficulty: 🔵🔵🔵🔵🔵