首页 > 解决方案 > 在python中打破if语句

问题描述

我想打破 if 语句。

我的代码是这样的:

if a == 0 or d == 0:
    while a>0:
        d=a//b
        c+=1
        a=d//b
        c+=1
    break

我收到一个错误,叫做'break' outside loop我能做什么。

标签: pythonif-statement

解决方案


您不能“破坏” if 语句。你可以“打破”while循环。您可以在 while 循环中添加“if”语句来中断它


推荐阅读