Created
June 21, 2022 06:15
-
-
Save blacksmithop/d281e2e28c5d0a67bcfa4c47c910ccba to your computer and use it in GitHub Desktop.
python 3.10 switch case example list elements
This file contains hidden or 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
| # 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