【发布时间】:2017-02-19 08:56:54
【问题描述】:
我想知道如何在 Python 中按特定顺序遍历列表。
给定列表lst = [1, 3, -1, 2],我希望我的函数进行迭代,以便迭代的下一个数字将是当前数字值的索引。
lst[0] -> lst[1] -> lst[3] -> lst[2] 1 -> 3 -> 2 -> -1
【问题讨论】:
-
这是实际要求的问题之一:为什么你想这样做?
标签: python loops for-loop iteration next