Use filter,map,reduce in lambda functions.
items = [1,2,3,4,5,6]
code:
map function
items = [1,2,3,4,5,6]
new_items = list(map(lambda x:x*x,items))
print(new_items)
Output: [1, 4, 9, 16, 25, 36]
filter function
items = [1,2,3,4,5,6]
new_items = list(filter(lambda x:(x%2==0),items))
print(new_items)
Output: [2, 4, 6]
reduce function
from functools import reduce
items = [1,2,3,4,5,6]
new_items = reduce((lambda x,y:x+y),items)
print(new_items)
Output: 21
#softwareengineer #pythonlearning #computerscience #coder #phyton #python3 #pythoncode #pythonprogramming #shorts #youtubeshorts
On this page of the site you can watch the video online map() filter() reduce() in lambda | Python Function | map | filter | reduce | lambda with a duration of hours minute second in good quality, which was uploaded by the user Mangesh Bagul 19 February 2022, share the link with friends and acquaintances, this video has already been watched 2,269 times on youtube and it was liked by 91 viewers. Enjoy your viewing!