The python 3 nonlocal keyword marks a variable as one taken from a parent scope, and is similar to the global keyword.
The nonlocal
keyword (introduced in Python 3), lets you mark a variable as one that is to be taken from a parent scope. It can only be used in a nested function and the variable must exist in the nesting scope (unlike the global
keyword).