What will be the output of the following Python code?
def foo(i, x=[]):
x.append(x.append(i))
return x
for i in range(3):
y = foo(i)
print(y)
def foo(i, x=[]):
x.append(x.append(i))
return x
for i in range(3):
y = foo(i)
print(y)A. [[[0]], [[[0]], [1]], [[[0]], [[[0]], [1]], [2]]]
B. [[0], [[0], 1], [[0], [[0], 1], 2]]
C. [0, None, 1, None, 2, None]
D. [[[1]], [[[0]], [1]], [[[0]], [[[0]], [1]], [2]]]
Answer: Option C

Join The Discussion