dimanche 13 juin 2021

How does an "if" statement differ from "mtach/case" statment in Python?

This question asks for a switch/case or match/case equivalent in Python. It seems since Python 3.10 we can now use match/case statement. I cannot see and understand the difference between match/case and an if, elif statement other than the syntactical differences!

Is there an underlying difference which makes them have different performance? or Somehow using match/case we can control the flow better? but How? Is there an example in which match/case is better than just an if statement?

Aucun commentaire:

Enregistrer un commentaire