When working with various sequences in Python, you can use the enumerate () function if we want to display the elements of the sequence and their subscripts .
The enumerate () function is used to iterate through the elements in the sequence and their subscripts, using the following:
1. The parameter is a tuple of tuple:
For index, value in enumerate (' A ', ' B ', ' C '): ' Subscript , Element ' ' print (index,value)
2. The parameter is a list of lists:
For index, value in enumerate ([1, 2, 3]): ' subscript, Element ' ' print (index, value)
3. The parameter is a string of strings:
For index, value in enumerate (' abc '): ' subscript, Element ' ' print (index, value)
4. The parameter is a dictionary dict:
For index, value in enumerate ({' A ': 1, ' B ': 2}): ' subscript (dictionary unordered), element (key value) ' print (index, value)
[Python Supplements]enumerate () function