How to get list index and element simultaneously in Python? [duplicate]
You can use enumerate: for k,i in enumerate(mylist): #do something with index k #do something with element i More information about looping techniques. Edit: As pointed out in the comments, using other variable names like for i, item in enumerate(mylist): makes it easier to read and understand your code in the long run. Normally you … Read more