adplus-dvertising
frame-decoration

Question

Which of the following is the correct expansion of list_1 = [expr(i) for i in list_0 if func(i)] ?

a.


list_1 = []
for i in list_0:
if func(i):
list_1.append(i)

b.


for i in list_0:
if func(i):
list_1.append(expr(i))

c.


list_1 = []
for i in list_0:
if func(i):
list_1.append(expr(i))

d.

none of the mentioned

Posted under Python

Answer: (c).
list_1 = []
for i in list_0:
if func(i):
list_1.append(expr(i))

Engage with the Community - Add Your Comment

Confused About the Answer? Ask for Details Here.

Know the Explanation? Add it Here.

Q. Which of the following is the correct expansion of list_1 = [expr(i) for i in list_0 if func(i)] ?