Examveda

What will be the output of the following Python code?
a=[1,2,3,4]
b=[sum(a[0:x+1]) for x in range(0,len(a))]
print(b)

A. 10

B. [1,3,5,7]

C. 4

D. [1,3,6,10]

Answer: Option D


This Question Belongs to Python Program >> Lists In Python

Join The Discussion

Related Questions on Lists in Python