私信  •  关注

Landar

Landar 最近创建的主题
Landar 最近回复了
5 年前
回复了 Landar 创建的主题 » 跳过python中的索引
li = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]
condition3_reached = False
condition10_reached = False
for i in li:
    print(i)
    if conditition3_reached and not condition10_reached and i != 10:
        continue
    if condition3_reached and i == 10:
        condition10_reached = True
    if i == 3 and (#along with other condition):
        condition3_reached = True
        print(i)
    else:
        do_some_new_thing_for_10_onwards()

这是一个简单的实现你想要的东西的方法。我担心它不可扩展