def foo()global 'ais in global namespace foo( is now is still python supports nested function definitions here' an exampledef countdown(start) start def display()nested function definition print(' -minus %dnwhile display( - variables in nested functions are bound using lexical scoping that isnames are resolved by first checking the local scope and then all enclosing scopes of outer function definitions from the innermost scope to the outermost scope if no match is foundthe global and built-in namespaces are checked as before although names in enclosing scopes are accessiblepython only allows variables to be reassigned in the innermost scope (local variablesand the global namespace (using globalthereforean inner function can' reassign the value of local variable defined in an outer function for examplethis code does not workdef countdown(start) start def display()print(' -minus %dndef decrement() - fails in python while display(decrement(in python you can work around this by placing values you want to change in list or dictionary in python you can declare as nonlocal as followsdef countdown(start) start def display()print(' -minus %dndef decrement()nonlocal bind to outer (python onlyn - while display(decrement(the nonlocal declaration does not bind name to local variables defined inside arbitrary functions further down on the current call-stack (that isdynamic scopesoif you're coming to python from perlnonlocal is not the same as declaring perl local variable lib fl ff