Understand Python variable scope — global, local, nonlocal, and LEGB rule. Avoid the common pitfalls.