How does python for get the number of current loops?
From: http://markmail.org/message/ryfven2i75kgsrsm
Enumerate is a new built-in function in Python 2.3. Its English description is as follows:
Enumerate (iterable)
Return an enumerate object. iterable must be a sequence, an iterator, or some other object which supports iteration. the next () method ofthe iterator returned by enumerate () returns a tuple containing acount (from zero) and the corresponding value obtained from
Iteratingover iterable. enumerate () is useful for obtaining an indexed series :( 0, seq [0]), (1, seq [1]), (2, SEQ [2]),... new in version 2. 3. this function is especially suitable for a for loop, and can be used when we need both counts and elements. For example, there is a string array that needs to be printed in one row, and the count is added before each row, starting from 1.
S = ['abc', 'This is a test', 'Hello, python']
For I, line in enumerate (s ):
Print I + 1, line