Page 1 of 1

The single line equivalent of the following Python code?

Posted: Wed Jul 13, 2022 7:45 pm
by answerhappygod
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)