adplus-dvertising
frame-decoration

Question

The single line equivalent of the code shown below is:
l=[1, 2, 3, 4, 5]
def f1(x):
    return x<0
m1=filter(f1, l)
print(list(m1))

a.

filter(lambda x:x<0, l)

b.

filter(lambda x, y: x<0, l)

c.

filter(reduce x<0, l)

d.

reduce(x: x<0, l)

Posted under Python

Answer: (a).filter(lambda x:x<0, l)

Engage with the Community - Add Your Comment

Confused About the Answer? Ask for Details Here.

Know the Explanation? Add it Here.

Q. The single line equivalent of the code shown below is: