for i,x in enumerate() function explanation

Enumerate is the meaning of enumeration, which lists the elements one by one, what is the first one, and what is the second one, so what it returns is the element and the corresponding index.

>>> line = [1,2,3,4,5]
>>> for i,j in enumerate(line):
...     print(i,j)
...
0 1
1 2
2 3
3 4
4 5

Guess you like

Origin blog.csdn.net/weixin_45598506/article/details/112477795