Get loop count inside a for-loop [duplicate]

The pythonic way is to use enumerate:

for idx, item in enumerate(my_list):

Leave a Comment