Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

structural pattern matching python

# Structural pattern matching allows you to write switch/case statements
# in Python. You need to have Python 3.10 to use this feature.
x = 10
match x:
    case 10:
        print('x = 10') # if x is 10, this will print 10
    case 20:
        print('x = 20') # if x is 20, this will print 20
    case _:
        # The underscore allows you to write a default case if none of the
        # conditions above are true.
        print(f'x = {x}')
Comment

PREVIOUS NEXT
Code Example
Python :: python logging levels 
Python :: convert blocks to mb python 
Python :: python utf upper() 
Python :: random number list 
Python :: a star search algorithm python code 
Python :: django give access to media folder 
Python :: string to list 
Python :: how to add find the smallest int n in a list python 
Python :: numpy variance 
Python :: scrapy access settings from spider 
Python :: reverse string in python without using function 
Python :: python odd or even 
Python :: convert file dta in csv 
Python :: 151 problem solution 
Python :: odoo docker addons path 
Python :: length of dictionary python 
Python :: NumPy resize Syntax 
Python :: google scikit learn decision tree 
Python :: re sub python 
Python :: Run a Flask API from CMD 
Python :: color module python 
Python :: get Fiscal year 
Python :: how to install python packages in local directory 
Python :: how to get all 5 letter words in python 
Python :: binary tree python 
Python :: mean bias error 
Python :: how to print tables using python 
Python :: how to import files from desktop to python 
Python :: quick sort algorithm in python 
Python :: is plaindrome python 
ADD CONTENT
Topic
Content
Source link
Name
4+2 =