Tag: Element Ror class focuses on seq str tuple parameter logs
Welcome to follow Me blog: Cloud Dreamer
Describe
The enumerate () function is used to combine a traversal object (list, tuple, or string) into an index sequence, listing both the data and the data subscript, which is typically used in a for loop.
Grammar
enumerate(sequence, [start=0])
Parameters
- Sequence--a sequence, iterator, or other supporting iteration object.
- Start-the subscript start position.
return value
Returns the enumerate (enum) object.
Instance
Example code:
>>>Seasons=[' Spring ',' Summer ',' Fall ',' Winter ']>>> List(Enumerate(seasons)) [(0,' Spring '), (1,' Summer '), (2,' Fall '), (3,' Winter ')]>>> List(Enumerate(Seasons, start=1))# Small Mark starting from 1[(1,' Spring '), (2,' Summer '), (3,' Fall '), (4,' Winter ')]
For loop and its combined use
>>>= [‘one‘‘two‘‘three‘]>>>forinenumerate(seq):... print0 one1 two2 three
Python Enumerate ()