map filter lambda python code example
Example 1: python filter
number_list = range(-5, 5)
less_than_zero = list(filter(lambda x: x < 0, number_list))
print(less_than_zero)
# Output: [-5, -4, -3, -2, -1]
Example 2: filter function using lambda in python
#filter function
nums1 = [2,3,5,6,76,4,3,2]
bads = list(filter(lambda x: x>4, nums1))
print(bads)
Example 3: map function using lambda in python
# Map function
nums1 = [2,3,5,6,76,4,3,2]
sq = list(map(lambda a : a*a, nums1))
print(sq)