Python Leave Loop Early

后端 未结 4 2216
执念已碎
执念已碎 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:36

    continue and break is what you want. Python works identically to Java/C++ in this regard.

提交回复
热议问题