Python map() Function

Ankur Agarwal
Apr 25, 2021

--

The advantage of the lambda operator can be seen when it is used in combination with the map() function. map() is a function with two arguments:

r = map(function_name , seq)

The first argument function_nameis the name of a function and the second a sequence (e.g. a list) seq. map() applies the function function_name to all the elements of the sequence seq. It returns a new list with the elements changed by funcfunction_name.

Python code

Function map() can be applied to more than one list. The lists have to have the same length. map() will apply its lambda function to the elements of the argument lists, i.e. it first applies to the elements with the 0th index, then to the elements with the 1st index until the n-th index is reached:

map() with more than one list.

Follow me on linkedin.com.

https://www.linkedin.com/in/ankurjavaarch

--

--

No responses yet