I find myself in the need of counting through lists with the help of for loops. What I end up doing is this:
L = ['A','B','C','D']
n = 0
for i in L:
print(L[n])
n += 1
I was wondering if there is a better way for doing this, without having to declare an extra variable n
every time?
Please keep in mind that this is just a simplified example. A solution like this would not suffice (although in this example the results are the same):
L = ['A','B','C','D']
for i in L:
print(i)