map(function, iterable, *iterables)
Applies a specified function to each element of the given sequence (s).
Parameters
func: Function to apply to the elements of the sequence (s). It must accept a number of arguments equal to the number of sequences. IfNoneis passed, an identity mapping is assumed (lambda *args: args). If multiple sequences are passed, the result will contain tuples with data from each.iterable: A sequence (or iterable object) whose elements the function applies to. If any sequences have fewer elements than others, the missing elements are consideredNone. The iterator stops when the shortest sequence is exhausted.
Return Value
map()returns an iterator that applies the function to every item of the iterable, yielding the results.
Examples
func = lambda el1, el2: '%s|%s' % (el1, el2)
list(map(func, [1, 2], [3, 4, 5]))
# >>> ['1|3', '2|4']
dict(map(lambda *args: args, [1, 2], [3, 4]))
# >>> {1: 3, 2: 4}