【发布时间】:2022-01-15 19:05:34
【问题描述】:
我的问题有点难以描述,我想用一个例子来说明我的问题。
例如每个数字对应一个对应的值,
a=[0,3,5]
b=[0,1,2,3,4,5,6,7]
for i in range(b):
if i not in a:
if ***value of i < value of next i that meet the condition***
a.append(i)
else:
a.append(***next i that meet the condition***)
我想写这样的代码,但问题是我不知道如何表达满足条件的下一个i。简单地使用 i+1 肯定是错误的。有人可以帮助我吗?非常感谢你们!!
【问题讨论】:
-
你能指出你想在每一步附加到
a的值吗?
标签: python list python-2.7 loops