Map function in Python

 The map() function executes a specified function for each item in a iterable. The item is sent to the function as a parameter.





Code Example


>>> l1 = [1, 2, 3, 4, 5]
>>> l2 = [5, 4, 3, 2, 1]
>>> l3 = [5, 4, 3, 2, 1]

>>> def cal(a=0, b=0, c=0):
             print(a+b+c)

>>> x = map(cal, l1, l2, l3)
>>> x
<map object at 0x03FB6100>

>>> x = list(x)
Output:

11
10
9
8
7

Quiz Level 1

Quiz Level 2


Request Me





Comments

Popular posts from this blog

How To Create .ENV File in Python

Create a Large file for Test Data Processing using Python

How to solve the Liner Equation using Python