-
-
Save zrhans/f793148cfd2eb2164cbfdb368a6a26d6 to your computer and use it in GitHub Desktop.
Switch case using dict functions
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") | |
if __name__ == "__main__": | |
switch = { | |
"1": function1, | |
"2": function2 | |
} | |
case = switch.get("1", default) | |
case() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment