Quick actions

cmd+k|ctrl+k

Navigation

Languages

Inner function closure 2 

Snippet info

Language

Python

Visibility

public

Author

kachuntong01

Created

2025-06-23T06:31:14.8383Z

Updated

2025-06-23T06:36:42.204384Z

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