3 ms·
Yes, enumerate is useful for that. But even if you did not now about it you could have used count from itertools to get the same effect: import itertools
by eru 16y ago
Yes, enumerate is useful for that. But even if you did not now about it you could have used count from itertools to get the same effect:
import itertools
for (index, item) in zip(itertools.count(0), "hallo"):
print index, item
Itertools is worth checking out for other goodies, too.