Python: use izip for iterating over multiple lists

I know I'll forget this again, so I'll blog it.
from itertools import izip

xlist = [1, 2, 3]
ylist = [5, 6, 7]

for x, y in izip(xlist, ylist):
print x, y

1 5
2 6
3 7
This also works for more than two lists. Zip() and map() also work but izip() should use less memory and perh


Popular posts from this blog

Shortest Sudoku solver in Python

Seven Segment Display in Inkscape