""" File: local3.py Python allows local functions to be defined. Below the local function B can be seen in the body of local function C, since C can see all of A's local variables However, B cannot see C's local variables (or vice versa). """ def A(n): def B(y): nonlocal a a = a + 1 return y + a def C(z) : b = B(z) c = B(b) a = 0 # not the one in A return c a = 2*n x = C(7) print("a = " + str(a)) return x r = A(2) print ("r = " + str(r))