Skip to content

Instantly share code, notes, and snippets.

@duducp
Last active October 17, 2023 02:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save duducp/f4730d849cbc065e6449dc1d6c03d439 to your computer and use it in GitHub Desktop.
Save duducp/f4730d849cbc065e6449dc1d6c03d439 to your computer and use it in GitHub Desktop.
Switch case using dict functions
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