enumerate
essentially turns each element of the input list into a list of tuples with the first element as the index and the element as the second. enumerate(['one', 'two', 'three'])
therefore turns into [(0, 'one'), (1, 'two'), (2, 'three')]
The bit just after the for
pretty much assigns i
to the first element and element
to the second for each tuple in the enumeration. So for example in the first iteration, i == 0
and element == 'one'
, and you just go through the other tuples to get the values for the other iterations.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…