Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 8. Functions > Using map to Apply a Function to Sequence Items

Using map to Apply a Function to Sequence Items

The map() function takes a function and one or more sequences as arguments. It repeatedly calls the function, using the sequence items in turn as arguments, and returns a list containing the values returned by each function call.

To use map to apply a function to sequence items:

  • Type map(func, seq1 [,seq2,...])

    func is a function or other callable object, and seq1, seq2,… are one or more comma-separated sequences (strings, lists, or tuples) whose items are passed to func. func must take as many arguments as there are sequences. map() always returns a list no matter what sequence types you pass it.


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint