Scope and the Global Keyword

Talk it through with a coach who asks guiding questions and gives hints until you reach the answer. Pass to mark the challenge as completed.

The problem

  • medium
  • Pro

A function reads a module-level counter fine, but as soon as it adds one to the counter, Python raises an unbound local error. Explain Python's scope rules and why this happens.

Talk this problem through with an AI coach

This is a Pro challenge. Sign in with Google, then upgrade to start a voice session.

Start free →