What will be the output of the following Python code? [code]def foo(i, x=[]): x.append(x.append(i)) return x for i in range(3):

What will be the output of the following Python code?
Code:
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. [[[0]], [[[0]], [1]], [[[0]], [[[0]], [1]], [2]]]
 

Tìm kiếm

Back
Top