[Tutor] Multiple Simultaneous Loops

Ed Singleton singletoned at gmail.com
Thu Sep 15 10:56:39 CEST 2005

I roughly want to be able to do:

for f, x in bunch_of_files, range(z):

so that x iterates through my files, and y iterates through something else.

Is this something I can do?

If so, what would be the best way to create a range of indeterminate length?

If not, is there a nice way I can do it, rather than than incrementing
a variable (x = x + 1) every loop?

Or maybe can I access the number of times the loop has run?  ('x = x +
1' is so common there must be some more attractive shortcut).

So far in learning Python I've founbd that when I feel you should be
able to do something, then you can.  This seems a pretty intuitive
thing to want to do, so I'm sure it must be possible, but I can't find
anything on it.

Many thanks


More information about the Tutor mailing list