Python OOPs


Examples


Others


How to pass index and value in map() method in Python


Write a Python program to pass index and values in map() method in Python.

pgm.py
a=[1,2,3,4,5]
def sq(i) :
    index,value=i
    return value**(index+1)
            		
x=list(map(sq,enumerate(a)))
print(x)
Output:
[1, 4, 27, 256, 3125]