You can define a default case in Python. For this you use a wild card (_
). The following code demonstrates it:
x = "hello"
match x:
case "hi":
print(x)
case "hey":
print(x)
case _:
print("not matched")
You can define a default case in Python. For this you use a wild card (_
). The following code demonstrates it:
x = "hello"
match x:
case "hi":
print(x)
case "hey":
print(x)
case _:
print("not matched")