Briefly describe the enumerate function

We often see the enumerate function appearing in the code. The meaning it represents is that this function combines a traversable object (dictionary, list, tuple, string) into a new sequence, listing the data and the data below Standard
such as:

list = ['p','y','t','h','o','n']
for i in enumerate(list):   
	print(i)

The result of the operation is
(0,'p')
(1,'y')
(2,'t')
(3,'h')
(4,'o')
(5,'n')
Visible, this function will list index arrangement

Guess you like

Origin blog.csdn.net/weixin_48445640/article/details/108810851