Skip to main content

Python Map Function

The map() function returns map object after applying a given function to each item of an iterable (list, tuple etc.) .

Syntax:

map(function, iterables)

Parameters:

  • function : It is a function to which map passes each element of given iterable.
  • iterables : It is used to map.

Return Values:

It return value from map() (map object) after applying the given function to each item of a given iterable (list, tuple etc.).

Example:

def power(n):
    return n ** 2
num = (1,2,3,4,5,6)
res = (map(power,num))
print(list(res))

Output: [1, 4, 9, 16, 25, 36]

Tags
Submitted by devanshi.srivastava on July 8, 2021

Devanshi, is working as a Data Scientist with iVagus. She has expertise in Python, NumPy, Pandas and other data science technologies.

About

At ProgramsBuzz, you can learn, share and grow with millions of techie around the world from different domain like Data Science, Software Development, QA and Digital Marketing. You can ask doubt and get the answer for your queries from our experts.