Python map function

The map() function applies a given function to each item of an iterable (list, tuple etc.) and returns a list of the results.

The syntax of map() is:


map() Parameter

  • function – map() passes each item of the iterable to this function.
  • iterable iterable which is to be mapped

You can pass more than one iterable to the map() function.


Return Value from map()

The map() function applies a given to function to each item of an iterable and returns a list of the results.

The returned value from map() (map object) then can be passed to functions like list() (to create a list), set() (to create a set) and so on.

Example: How map() works?

output

[Total: 1    Average: 5/5]
admin
Leave a Reply

Generic selectors
Exact matches only
Search in title
Search in content
Search in posts
Search in pages