filter() in Python

Source code :

numbers = [0,1,1,2,3,5,8,13,21,34,55]
odd_numbers = list(filter(lambda x: x % 2, numbers))
print(odd_numbers)

even_numbers = list(filter(lambda x: x % 2 == 0, numbers))
print(even_numbers)

Output :

[1, 1, 3, 5, 13, 21, 55]
[0, 2, 8, 34]

Output :


                

Comments :