Index
Definition
map() function returns a map object(which is an iterator) of the results after applying the given function to each item of a given iterable (list, tuple etc.)
oss:
if you what to print the result of map you have to translate i to a list or tuple or set (ex: list(map) ,set(map) …)
- this because map returns the address of map object example
Syntax
Parameter
fun: - It is a function to which map passes each element of given iterable.
iterables: It is iterable which is to be mapped.
NOTE: You can pass one or more iterable to the map() function.
Return
- Returns a list of the results after applying the given function to each item of a given iterable (list, tuple etc.)
Example
One Iterator:
labda version:
Why list(map(...))
because if you print(map) without the list you will print
Two Iterator:
Advanced Two Iterators:
labda version: