Register Now

Login

Lost Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

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

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

Answer: c
Explanation: We have to create an empty list, loop over the contents of the existing list and check if a condition is satisfied before performing some operation and adding it to the new list.

Join The Discussion