Report Bug

Qus

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)
Qusनिम्नलिखित Python कोड का आउटपुट क्या होगा?


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


Solution
C. [0, None, 1, None, 2, None]



Explanation
append() returns None.
CCC Online Test Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Online Exam Quiz O Level NIELIT Study material and Quiz Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Best Website and Software Company in Allahabad Website development Company in Allahabad