Posted By

iamok on 04/28/10


Tagged

python lists


Versions (?)

adding elements of two lists


 / Published in: Python
 

  1. summed = [sum(pair) for pair in zip(listA, listB)]
  2.  
  3. or
  4.  
  5. from operator import add
  6. summed = map(add,listA,listB)
  7.  
  8. or
  9.  
  10. summed = map(sum,zip(listA,listB))

Report this snippet  

You need to login to post a comment.