for items in things:
while inputFloat != 0:
thingsBack[][1]=inputFloat//things[]
inputFloat=inputFloat-(things[]*thingsBack[][1])
things 是一个包含 n 个元素的列表,而 thingsBack 是一个包含 n 个子列表的列表。我希望 things 和 thingsBack 从第 0 个元素开始并循环递归。计算inputFloat//things[]只改变thingsBack中第j个子列表的1索引。我知道 [] 是无效语法,但用于说明目的。
似乎有一个明显的解决方案,但我没有看到它。
最佳答案
猜测一下,我认为您正在寻找 for 循环中当前项目的索引?
for index, items in enumerate(things):
# do stuff using index
看看这个:
关于python:在子列表的索引上运行循环,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35030662/