<aside>

<aside> <img src="/icons/reorder_gray.svg" alt="/icons/reorder_gray.svg" width="40px" />

Navigation

</aside>

</aside>

<aside>

Match-Case Statements


Syntax:

match value:
    case pattern1:
        #Code to execute if value matches pattern1
    case pattern2:
        #Code to execute if value matches pattern2
    case _:
        #Default case (if no pattern match)

Example:

name = "Hisham"

match name:
    case "Hisham":
        print(f"success {name} has found" )
    case "john":
        print("failure")
    case _:
        print("not found")

Output:

<aside> success Hisham has found

</aside>