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
En esta página del sitio puede ver el video en línea map() filter() reduce() in lambda | Python Function | map | filter | reduce | lambda de Duración hora minuto segunda en buena calidad , que subió el usuario Mangesh Bagul 19 febrero 2022, comparta el enlace con amigos y conocidos, en youtube este video ya ha sido visto 2,269 veces y le gustó 91 a los espectadores. Disfruta viendo!