Examveda

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))

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


This Question Belongs to Python Program >> Functions In Python

Join The Discussion

Related Questions on Functions in Python