Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

Python Create a nonlocal variable

def outer():
    x = "local"

    def inner():
        nonlocal x
        x = "nonlocal"
        print("inner:", x)

    inner()
    print("outer:", x)


outer()
Comment

PREVIOUS NEXT
Code Example
Python :: negative indexing in python 
Python :: embed variables python 
Python :: python tuple 
Python :: python single line comment 
Python :: python3 format leading 0 
Python :: merge two sorted arrays python 
Python :: how delete element from list python 
Python :: combining strings 
Python :: seaborn and matplotlib python 
Python :: yaml validator python 
Python :: python merge two array into one 
Python :: bot delete embed py 
Python :: turtle python 
Python :: pandas check if column is object type 
Python :: replace in lists py 
Python :: how to calculate log 10 in python 
Python :: how to iterate set in python 
Python :: python linux script 
Python :: print on same line 
Python :: getting tradingview historical data using python 
Python :: python for loop 
Python :: python 2d array append 
Python :: CVE-2018-10933 
Python :: random playing card generator python 
Python :: python remove header 
Python :: dont truncate dataframe jupyter pd display options 
Python :: python puissance 
Python :: python wheel 
Python :: mosaicplot pandas 
Python :: python code to demonstrate inheritance with animal class 
ADD CONTENT
Topic
Content
Source link
Name
2+4 =