Skip to content

Instantly share code, notes, and snippets.

@blacksmithop
Created June 21, 2022 06:15
Show Gist options
  • Select an option

  • Save blacksmithop/d281e2e28c5d0a67bcfa4c47c910ccba to your computer and use it in GitHub Desktop.

Select an option

Save blacksmithop/d281e2e28c5d0a67bcfa4c47c910ccba to your computer and use it in GitHub Desktop.
python 3.10 switch case example list elements
# Python 3.10 switch case example for a list
def file_handler_v1(command):
match command.split():
case ["show"]:
print("List all files and directories: ")
# code to list files
case ["remove", *files]:
print("Removing files: {}".format(files))
# code to remove files
case _:
print("Command not recognized")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment