If run the above snippet, an error would be thrown
UnboundLocalError: local variable 'var' referenced before assignment
Python nonlocal keyword is used to make the variable which refers to the variable bounded in the nearest scope. Scope to which variable it bound should not be global or local scope. In Python nonlocal variable follows different behavior from identical binding, It searches for variables in another scope. The nonlocal variable is used in the nested function. nonlocal variable is used in declaring the variable.