1. Home
  2. Data Science
  3. Python
  4. Inside a nested function, which keyword lets you reassign…

Added 2 Nov 2026

Inside a nested function, which keyword lets you reassign a variable from the enclosing (outer) function?

  1. nonlocal Correct answer
  2. outer
  3. static
  4. global

Correct answer

A. nonlocal

22 views

MCQSEXAM

Explanation

nonlocal binds to the nearest enclosing function scope, which is useful in closures such as counters. global refers to module-level variables.

Reference

Asked in: NTS, Python Developer Interviews

Preparing for an exam?

Doubts & discussion

Not sure why the answer is A? Ask here and get an explanation.

Ask a doubt about this MCQ

Shown after review. No links please.

More Python MCQs

Practise all Python MCQs

Similar MCQs