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

What is the output?

def f(n, acc=[]):
    acc.append(n)
    return acc
f(1)
print(f(2))
  1. [1, 2]
  2. [2]
  3. [1]
  4. [[1], [2]]
The default list is created once, so it persists between calls.
Play Problem Solving ▸