enumerate(sequence, [start=0])
sequernce是你的序列,start是开始的下标
a=[1,2,3,4,5]
list(enumerate(a))
[(0, 1), (1, 2), (2, 3), (3, 4), (4, 5)]
for i in enumerate(a):
print(i)
(0, 1)
(1, 2)
(2, 3)
(3, 4)
(4, 5)
for i,element in enumerate(a):
print(i,element)
0 1
1 2
2 3
3 4
4 5