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.)
fun : It is a function to which map passes each element of given iterable.
iter : It is a iterable which is to be mapped.
NOTE : You can pass one or more iterable to the map() function.
Returns a list of the results after applying the given function to each item of a given iterable (list, tuple etc.)
NOTE : The returned value from map() (map object) then can be passed to functions like list() (to create a list), set() (to create a set) .
[2, 4, 6, 8]
We can also use lambda expressions with map to achieve above result.
[2, 4, 6, 8]
[5, 7, 9]
[['s', 'a', 't'], ['b', 'a', 't'], ['c', 'a', 't'], ['m', 'a', 't']]
- Python map function to find row with maximum number of 1's
- Python - pass multiple arguments to map function
- Python Map | Length of the Longest Consecutive 1's in Binary Representation of a given integer
- Python - Map vs List comprehension
- Intersection of two arrays in Python ( Lambda expression and filter function )
- Prefix sum array in Python using accumulate function
- join() function in Python
- Python | fsum() function
- Python list function | count()
- Python program to check if the list contains three consecutive common numbers in Python
- Python List Comprehension and Slicing
- List Methods in Python | Set 1 (in, not in, len(), min(), max()...)
- List Methods in Python | Set 2 (del, remove(), sort(), insert(), pop(), extend()...)
- List methods in Python
- Python | Set 3 (Strings, Lists, Tuples, Iterations)
- Output of Python program | Set 6 (Lists)
- Output of python program | Set 11(Lists)
- Output of Python Programs | Set 18 (List and Tuples)
- Python | Converting all strings in list to integers
- Stack and Queues in Python