-
-
Save zrhans/2c9853b2bc83619be66a6212c1ac038a to your computer and use it in GitHub Desktop.
Switch case with if/else
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def function1(): | |
print("Case 1 selected") | |
def function2(): | |
print("Case 2 selected") | |
def default(): | |
print("Value default") | |
def switch(case): | |
if case == "1": | |
return function1 | |
elif case == "2": | |
return function2 | |
else: | |
return default | |
if __name__ == "__main__": | |
function = switch(case="1") | |
function() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment