我正在编写一个在 while 循环中包含 while 循环的代码,我想知道如果我在内循环中满足必要条件,如何跳出外循环。
while N <= 8:
while i < 60:
if this:
that
elif this:
that other thing
else:
break
i += 1
if while loop has found the right thing:
N += 1
else:
change conditions
这个 break 命令只会跳出第一个循环,所以我想知道如何简单地跳出两个循环。可能值得一提的是,所有这些都在另一个我不想跳出的 for 循环中。谢谢。
请您参考如下方法:
封装成一个函数,完成后返回?
