Match Case Statement
Introduced in Python 3.10, the match case statement offers a powerful mechanism for pattern matching in Python. It allows us to perform more expressive and readable conditional checks. Unlike traditional if-elif-else chains, which can become unwieldy with complex conditions, the match-case statement provides a more elegant and flexible solution.
x = 30
match x:
case 10:
print("It's 10")
case 20:
print("It's 20")
case 15:
print("its 15")
case _:
print("It's neither 10 nor 20 nor 15")