Tuesday, 10 September 2013

Element-wise Addition of 2 Lists in Python?

Element-wise Addition of 2 Lists in Python?

I have now:
list1=[1, 2, 3]
list2=[4, 5, 6]
I wish to have:
[1, 2, 3]
+ + +
[4, 5, 6]
||
[5, 7, 9]
Simply an element-wise addition of two lists.
I can surely iterate the two lists, but I don't want do that.
What is the most Pythonic way of doing so?

No comments:

Post a Comment