【发布时间】:2020-10-28 10:01:36
【问题描述】:
我想在 if 条件中使用 break 语句来中断 main while 循环
a = 0
b = True
while b:
print(a)
while a < 10:
if a == 8:
b = False
break # want to break both while loops using this command
else:
print(a)
a += 1
结果应该是 0 0 1 2 3 4 5 6 7
【问题讨论】:
-
请提及您遇到的困难,我们很乐意为您提供帮助,但无法为您编写代码
标签: python if-statement while-loop conditional-statements break