Python Map
Python Map
____________________________________________
The map() function applies a given function to each item of an
iterable (list, tuple etc.) and returns a list of the results.
map() Parameter
function - map() passes each item of the iterable to this function.
iterable -iterable which is to be mapped
You can pass more than one iterable to the map() function.
numbers = (1, 2, 3, 4)
result = map(calculateSquare, numbers)
print(result)
# converting map object to set
numbersSquare = set(result)
print(numbersSquare)
Program:
num1 = [4, 5, 6]
num2 = [5, 6, 7]
result = map(lambda n1, n2: n1+n2, num1, num2)
print(list(result))