Python enumerate函数

enumerate() 可以在遍历时同时拿到索引和值。

for i, value in enumerate(values):
    print(i, value)

适合需要“位置 + 元素”的场景。

相关:Python for循环Python列表