Python Leave Loop Early

后端 未结 4 2231
执念已碎
执念已碎 2020-12-11 00:10

How do I leave a loop early in python?

for a in b:
    if criteria in list1:
        print \"oh no\"
        #Force loop i.e. force next iteration without go         


        
4条回答
  •  长情又很酷
    2020-12-11 00:22

    continue and break work exactly like in other programming languages, except that you cannot break to a label (as you can in Java, for example). That means you can only break one loop at a time.

提交回复
热议问题