Skip to content
CodeWiki
Practice
Paths
Tracks
Cheatsheets
Playground
Glossary
AI era
Search
⌘K
English
English
Chinese
Practice
Paths
Tracks
Cheatsheets
Playground
Glossary
AI era
English
English
Chinese
Practice
/
Quiz
/
Python
/
Closures
An inner function executes count += 1, but count is bound only in the enclosing function.…
from Closures
Python 3.14
intermediate
1 min
An inner function executes count += 1, but count is bound only in the enclosing function. What happens without nonlocal count?
Python updates the enclosing binding automatically.
Python treats count as local, so the read raises UnboundLocalError.
Python creates or updates a module global named count.
Check
Ask AI about this kata
Report an error
previous kata
What does a Python closure capture for a free variable?
Quiz
next kata
What does this program print?
Predict the output
A new version is available
Reload