Python Function Examples with code
nonlocal
keyword is used inside a nested function to modify a variable from its enclosing (non-global) scope. Without nonlocal, assigning a new value to a variable inside a nested function creates a new local variable instead of modifying the one from the outer function.