using the for loop counter in python
Nov
17
1
0
Even with all the powerful tools Python loops do for you, sometimes you need to grab the good ol' loop counter.
There are a couple of different ways you can do this. The cleanest method that I found so far is to use the enumerate function. You can do something like this:
test = ['a', 'b', 'c'] for counter, value in enumerate(test): print counter, value