map for more than one iterable
Lets "add" together two lists of numbers. Using + will just join the two lists together, but we can use the "map" function to add the values pair-wise.
examples/functional/map_add.py
v1 = [1, 3, 5, 9] v2 = [2, 6, 4, 8] v3 = v1 + v2 print(v3) sums = map(lambda x,y: x+y, v1, v2) print(sums) print(list(sums))
[1, 3, 5, 9, 2, 6, 4, 8] <map object at 0x7fcbecc8c668> [3, 9, 9, 17]