Quick actions

cmd+k|ctrl+k

Navigation

Languages

closure

Snippet info

Language

Python

Visibility

public

Author

legacy-v1-22796

Created

2025-06-23T06:40:45.461955Z

Updated

2025-06-23T07:01:41.409742Z

def a():
    x = "python"
    def b():
        print("I am from inner function {0}".format(x))
    return b
    
c = a()
c()

x = 100
def outer():
    x = 1
    def inner1():
        nonlocal x
        # global x
        print("I am from inner function {0}".format(x))
        x = x + 1
    def inner2():
        nonlocal x
        # x = x + 1
        print("I am from inner2 function {0}".format(x))
        x = x + 1
    # inner2()
    # return inner1
    return inner1,inner2
# c = outer()
# c()
c,d = outer()
c()
d()
c()
d()
INFO