I'm iterating through a string and need to perform certain actions if the index number of a given character equals a certain value. However I'm not sure of the best way of keeping track of the current index number during the iteration. For example I need code that broadly does the following:
def myfunc(word):
for n in word:
if n[index] = 0:
do this
elif n[index] = 4:
do this
else:
do this
I just can't seem to find any inbuilt counter or function that allows me to keep track of the current iteration index. I could add a counter in as variable and just +1 after each loop but this seems clunky and I would have thought Python would know the current iteration number of "n" and could report it back?