What is the output of the following Python code snippet?
x = 2
match x:
case 1:
print('One')
case 2:
print('Two')
case _:
print('Three')
-
A
One
-
B
Three
-
C
Error
-
D
Two
Correct answer
7 views
Explanation
match/case (Python 3.10+) performs structural pattern matching.
Doubts & discussion
Not sure why the answer is D? Ask here and get an explanation.
Ask a doubt about this MCQ