Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

Python Create a nonlocal variable

def outer():
    x = "local"

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

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


outer()
 
PREVIOUS NEXT
Tagged: #Python #Create #nonlocal #variable
ADD COMMENT
Topic
Name
1+2 =