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/b6ffa5175660072ea62a51fe77d921af to your computer and use it in GitHub Desktop.
Save duducp/b6ffa5175660072ea62a51fe77d921af to your computer and use it in GitHub Desktop.
Switch case with if/else
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