What are the walrus operator and match statement?
Model answer
The walrus operator := assigns inside an expression: if (n := len(items)) > 10. match (Python 3.10+) is structural pattern matching, like a more powerful switch that can match on shapes of data. Use them when they make the code clearer, not shorter at any cost.
Learn this topic
The Python Standard Library: Dates, Counter, Statistics and More in the course Python for Beginners: Learn to Code with Real Projects.
Sign in to add your own answer.