Source Code:
(back to article)
def switch_example(case_value): if case_value == 1: print("case 1") elif case_value == 2: print("case 2") elif case_value == 3: print("case 3") else: print("default case") switch_example(1) # prints "case 1" switch_example(2) # prints "case 2" switch_example(3) # prints "case 3" switch_example(4) # prints "default case"
Result:
Report an issue