Possible Duplicates:
Iterate a list as tuples in python
How do I iterate over the tuples of the items of two or more lists in Python?
I have two iterables in Python and I want to go over them in pairs:
foo = (1,2,3)
bar = (4,5,6)
for (f,b) in some_iterator(foo, bar):
print "f: ", f ,"; b: ", b
should result in:
f: 1; b: 4
f: 2; b: 5
f: 3; b: 6
One way to do it is to iterate over the indeces:
for i in xrange(len(foo)):
print "f: ",foo[i] ,"; b: ", b[i]
But that seems somewhat unpythonic to me. Is there a better way to do it?