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

Join The Discussion