what does built in map function do python code example
Example 1: map in python 3
map(function, iterable, ...)
Example 2: map function in python
def addition(n):
return n + n
numbers = (1, 2, 3, 4)
result = map(addition, numbers)
print(list(result))
Example 3: map in python
'''try this instead of defining a function'''
a = [1,2,3,4]
a = list(map(lambda n: n+n, a))
print(a)
Example 4: map in python
def addition(n):
return n + n
numbers = (1, 2, 3, 4)
result = map(addition, numbers)
print(list(result))