$ ./guess_the_languageProblem Solving — predict the output
Problem Solving — predict the output · hard · #212

What is the output?

x = 5
def f():
    print(x)
    x = 3
f()
  1. 5
  2. 3
  3. Nothing
  4. Error
The assignment makes x local to the whole function, so reading it first raises UnboundLocalError.
Play Problem Solving ▸