Skip to content

Commit 0b442fa

Browse files
committed
Match Statement added
1 parent 632b145 commit 0b442fa

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

Basics/Match.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
def identify_value(value):
2+
match value:
3+
case 0:
4+
print("It's zero")
5+
case 1:
6+
print("It's one")
7+
case "hello":
8+
print("It's the string 'hello'")
9+
case _: # '_' Default case
10+
print("It's something else")
11+
12+
# Test cases
13+
identify_value(0) # Output: It's zero
14+
identify_value(1) # Output: It's one
15+
identify_value("hello") # Output: It's the string 'hello'
16+
identify_value(3.14) # Output: It's something else

0 commit comments

Comments
 (0)