Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

switch case python 3.10

def my_function(status):
    match status:
        case 400:
            return "Bad request"
        case 404:
            return "Not found"
        case 418:
            return "I'm a teapot"
        case _:
            return "Something's wrong with the internet"

# No need of break after case
Source by docs.python.org #
 
PREVIOUS NEXT
Tagged: #switch #case #python
ADD COMMENT
Topic
Name
3+2 =