while循环里面嵌套if判断语句break,该跳出哪个语句?

今天想确认一下break到底跟if 有没有关系,难道是跳出if 判断吗?
nonono,break只能跳出与之最近的for循环和while循环,跟if没有任何关系哦:

i=0
while i<100:
    if i<9:
        print(0)
    else:
        break
    i=i+1
print(i)
0
0
0
0
0
0
0
0
0
9

猜你喜欢

转载自blog.csdn.net/qq_43511299/article/details/114544417