Avoiding loop counters in Python
Loop counters in for loops are not generally considered to be Pythonic, it is usually better to loop directly over a list or other sequence.
There are particular situations where it might feel as if a loop counter is the only option. But there is usually a better way!
Here are a couple of new PythonInformer articles explaining techniques to avoid loop counters:
Using enumerate to provide an index count in a Pythonic way.
Using zip to loop over two lists at the same time.
If you would like to learn more advanced techniques, you might be interested in my book Functional Programming in Python.
Regards
Martin
