You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It is used for applying a function to an iterable object like a list, string or tuple. It takes the function and 1 or more iterable as arguments.
e.g.
`
def add_one(x):
return x+1
Activity
Aneousion commentedon Jan 1, 2023
It is used for applying a function to an iterable object like a list, string or tuple. It takes the function and 1 or more iterable as arguments.
e.g.
`
def add_one(x):
return x+1
i = [1,2,3]
print(list(map(add_one,i)))
THIS PRINTS [2, 3, 4]
Two iterables
def add_both(x, y):
return x + y
first = [2, 3, 4]
second = [1, 2, 3]
print(list(map(add_both, first, second)))
THIS PRINTS [3, 5, 7]
`