IndentationError:预期缩进的块,但似乎正确

时间:2019-05-27 20:41:12

标签: python indentation expected-exception

在我提供的代码中有一个

>IndentationError in line 10, or at the END of:

> while ((while_bolian == "") and (correct_count >= 0) and (total_count != 0)) or ((while_bolian == True) and (correct_count >= 0) and (total_count != 0)):

但是我所有的缩进看起来都是正确的,我正在使用pycharm,如果我将光标放在上面的代码行之后,它会显示Indent Expected

我已经对此错误进行了研究,但是似乎没有任何帮助。

    total_count = int(input("how many questions do you want to be in the quizz \n10.\n50.\n100.\n:"))
    try:
        while ((while_bolian == "") and (correct_count >= 0) and (total_count != 0)) or ((while_bolian == True) and (correct_count >= 0) and (total_count != 0)):
    except ValueError:
        print("please enter a question limit")

>     line 10
        except ValueError:
        ^
IndentationError: expected an indented block

> Process finished with exit code 1

1 个答案:

答案 0 :(得分:0)

while需要一条pass之类的指令,并带有额外的缩进。
现在while试图运行except
例如参见Python syntax for an empty while loop