【发布时间】:2023-11-30 20:06:01
【问题描述】:
为什么在从循环中断后执行额外的代码。我想停止代码并修改一些输入,但代码在中断后继续并给我一个错误。
if condition:
for i in range(n):
if another condition:
do_somthing
else:
flag = True
for i in range(n:
if condition:
do_something
else:
flag = True
while flag:
try:
print('Erorr')
break
except:
break
# if break, I don't want to execute the rest of the code
t = []
for i in range(0, n):
t.append(i)
【问题讨论】:
标签: python loops try-catch break