Files
python-examples/switch.py
2023-02-25 01:48:44 +09:00

17 lines
232 B
Python
Executable File

#!/usr/bin/python
def function_1():
return 1
def function_2():
return 2
def function_3():
return 3
switch = {1:function_1, 2:function_2, 3:function_3}
val = 2
function = switch[val]
result = function()
print(result)