Variable scope (LEGB), closures and nonlocal
Interview insights are lockedSee how often this is asked and which companies asked it with Buncho Pro.Explain Python's scoping rules.
- What is LEGB?
- What is a closure, and why do decorators depend on them?
- What do
globalandnonlocaldo? What does this code print and why?
count = 0
def inc():
count += 1
inc()