Skip to main content

Command Palette

Search for a command to run...

The map()

It executes a specified function for each item in a given iterable (list,tuple etc) and returns a map of an object….

Published
•1 min read•View as Markdown
The map()

Map Function in Python.

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.)

Syntax Syntax: map(fun, iter)

Parameters:

fun: It is a function to which map passes each element of given iterable.

iter: It is iterable which is to be mapped.

NOTE: You can pass one or more iterable to the map() function.

Returns: 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) .

Share if you found this insightful and follow me for more