Vidyalelo
Python · Q131

Functions in Python

Programming · Python · question 131

Q131

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]
Answer
C.
[1] [2] [3]
D.
[1] [1, 2] [1, 2, 3]

Answer: Option B

Solution

Answer: Option B
No explanation is given for this question Let's Discuss on Board