""" File: local4.py Python allows local functions to be defined. Local functions can have local functions nested inside as well. """ def A(n): def B(y): nonlocal a a = a + 1 return y + a def C(z) : def D(i) : b = B(i) c = B(b) return c a = 0 # not the one in A return D(z) a = 2*n x = C(7) print("a = " + str(a)) return x r = A(2) print ("r = " + str(r))