Map() Function

Map() Function

  • The map() function is similar to filter function but it acts on each element of the sequence and perhaps changes the elements.
  • The function can be applied on each element of sequence and generates new sequence.

Syntax: 

  • map(function, sequence)

Eg:  Without lambda  

Eg: With lambda

We can apply map() function on multiple lists also.But make sure all list should have same length.

Syntax:  

  • map(lambda x,y:x*y,l1,l2))
  • x is from l1 and y is from l2


Comments