Aga
0
Q:

js filter method in python

# a list contains both even and odd numbers.  
seq = [0, 1, 2, 3, 5, 8, 13] 
# result contains odd numbers of the list 
result = filter(lambda x: x % 2, seq) 
print(list(result)) 
# result contains even numbers of the list 
result = filter(lambda x: x % 2 == 0, seq) 
print(list(result)) 
# Output
[1, 3, 5, 13]
[0, 2, 8]
6
list( filter((lambda x: x < 0), range(-10,5)))
0

New to Communities?

Join the community