2025-01-09T14:30:26
This commit is contained in:
17
src0/switch.py
Executable file
17
src0/switch.py
Executable file
@@ -0,0 +1,17 @@
|
||||
#!/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)
|
||||
Reference in New Issue
Block a user