In [1]:
my_list = [1, 5, 4, 6, 8, 11, 3, 12]
new_list = list(filter(lambda x: (x%2 == 0) , my_list))
print(new_list)
In [5]:
my_list = [1, 5, 4, 6, 8, 11, 3, 12]
nl=list(filter(lambda y:(y%3==0),my_list))
nl
Out[5]:
In [3]:
# Program to double each item in a list using map()
my_list = [1, 5, 4, 6, 8, 11, 3, 12]
new_list = list(map(lambda x: x * 2 , my_list))
print(new_list)
In [6]:
my_list = [1, 5, 4, 6, 8, 11, 3, 12]
new_list = list(map(lambda x: x + 2 , my_list))
print(new_list)
In [ ]:
No comments:
Post a Comment