practicepython.in
python exercises
171 exercises

Daily #22 · 20 October 2026

Reading before writing Medium

What does this print?

count = 10

def show():
    print(count)
    count = 5

show()
  1. A5
  2. Braises UnboundLocalError
  3. Craises NameError
  4. D10
Show the answer

B: raises UnboundLocalError

Why: Because count is assigned somewhere in the function, Python treats it as local for the whole function, including the line before the assignment. The global is never looked at.

Play today’s puzzle →