Skip to content

Instantly share code, notes, and snippets.

@pykong
Last active November 21, 2017 22:33
Show Gist options
  • Save pykong/569d7c42c951f7423cec28a672cc3fb8 to your computer and use it in GitHub Desktop.
Save pykong/569d7c42c951f7423cec28a672cc3fb8 to your computer and use it in GitHub Desktop.
from itertools import izip // you may also just use zip
l = [(1, 2), (3, 4), (5, 6), (7, 8), (9, 0)]
result = [sum(x) for x in izip(*l)]
print(result)
>>> [25, 20]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment