Right now I am tracking my index in side the loop like this
index = 0
for entry in longList:
if entry == 'foo':
print index
index += 1
is there a better way to do this?
for index, entry in enumerate(longList):
if entry == 'foo':
print index
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With