LEGB order: look inside out
local: local scope
enclosing: the local scope of the nested parent
global: global scope
build_in: built-in function scope
The variable declared with the global keyword must be in the global scope, not in the nested scope. When you want to modify the variables in the nested parent scope (enclosing scope, outer non-global scope), the nonlocal keyword is required.
The nonlocal keyword is a new keyword in python3.