Intermediate Python
Q69 / 101

What does the nonlocal keyword do?

Correct! Well done.

Incorrect.

The correct answer is B) Declares that a variable in a nested function refers to the enclosing function's variable

B

Correct Answer

Declares that a variable in a nested function refers to the enclosing function's variable

Explanation

nonlocal x in a nested function allows modifying x from the enclosing (not global) scope, enabling closures that mutate state.

Progress
69/101