0% found this document useful (0 votes)
20 views

Python Match Case

Uploaded by

aditya kanna
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views

Python Match Case

Uploaded by

aditya kanna
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Python Match Case (switch case from other languages)

What is a ‘match-case’ statement?


For developers coming from languages like C/C++ or
Java know that there was a conditional statement
known as Switch Case. This Match-Case is the Switch
Case of Python which was introduced in Python 3.10.
Here we have to first pass a parameter then try to check
with which case the parameter is getting satisfied. If we
find a match we will do something and if there is no
match at all we will do something else.

syntax
match < var > :
case var1 :
[block of statements]
case var2 :
[block of statements]
case var_n :
[block of statements]
case _ :
[block of statements]

You might also like