Jair Trejo wrote: > I was wondering how and if it's possible to write a > loop in python > which updates two or more variables at a time. For > instance, something > like this in C: > > for (i = 0, j = 10; i < 10 && j < 20; i++, j++) { > printf("i = %d, j = %d\n", i, j); > }
>>> for i,j in zip(range(0, 10), range(10, 20)): ... print("i = %d, j = %d" % (i, j)) ... i = 0, j = 10 i = 1, j = 11 i = 2, j = 12 i = 3, j = 13 i = 4, j = 14 i = 5, j = 15 i = 6, j = 16 i = 7, j = 17 i = 8, j = 18 i = 9, j = 19 >>> -- Under construction -- http://mail.python.org/mailman/listinfo/python-list