首页 > 解决方案 > 为什么这会给出错误 [E0001:invalid syntax ()] 在 python 3 中

问题描述

我试图创建一个 else 语句来检查井字棋棋盘中是否有平局:

#Checking for a tie:
else:
    #The board's numbers:
    for i in range(1,10):
        #If all or the numbers are not on the board, and no one won or lose...
        if all(not(i in board):
            #...then there's a tie! 
            print("Tie!")
        #If no one loses or won, and there's no tie, then the game isn't over.
        else:
            pass

Python给说这行有问题:

if all(not(i in board):

这是错误:

E0001:invalid syntax (<string>, line 156)

怎么修线?

标签: pythonif-statementsyntax-error

解决方案


更改if all(not(i in board):if all(not(i in board)):


推荐阅读