Inside a nested function, which keyword lets you reassign a variable from the enclosing (outer) function?
Correct answer
A. nonlocal
22 views
A. nonlocal
22 views
nonlocal binds to the nearest enclosing function scope, which is useful in closures such as counters. global refers to module-level variables.
Asked in: NTS, Python Developer Interviews
Not sure why the answer is A? Ask here and get an explanation.