python代码在if之后不运行

时间:2018-05-30 16:16:49

标签: python

此后的代码如果不起作用,有什么想法吗?

if (sum((BoardValuesToWin[0], BoardValuesToWin[1], BoardValuesToWin[2])) and sum(
                (BoardValuesToWin[3], BoardValuesToWin[4], BoardValuesToWin[5])) and sum(
                (BoardValuesToWin[6], BoardValuesToWin[7], BoardValuesToWin[8])) and sum(
                (BoardValuesToWin[0], BoardValuesToWin[3], BoardValuesToWin[6])) and sum(
                (BoardValuesToWin[1], BoardValuesToWin[4], BoardValuesToWin[7])) and sum(
                (BoardValuesToWin[2], BoardValuesToWin[5], BoardValuesToWin[8]))) != 300 or (sum(
                (BoardValuesToWin[0], BoardValuesToWin[1], BoardValuesToWin[2])) and sum(
                (BoardValuesToWin[3], BoardValuesToWin[4], BoardValuesToWin[5])) and sum(
                (BoardValuesToWin[6], BoardValuesToWin[7], BoardValuesToWin[8])) and sum(
                (BoardValuesToWin[0], BoardValuesToWin[3], BoardValuesToWin[6])) and sum(
                (BoardValuesToWin[1], BoardValuesToWin[4], BoardValuesToWin[7])) and sum(
                (BoardValuesToWin[2], BoardValuesToWin[5], BoardValuesToWin[8]))) != -300:
                position1 = int(
                    input("Take a look at the NUMPAD and choose a number for the position of your marker!"))
                BoardValues[position1] = "X"
                BoardValuesToWin[position1] += 100
                switchToTurnOfO = False
                displayBoardAfter_X_Played()
            else:
                pass

我不知道是什么导致了它。

1 个答案:

答案 0 :(得分:0)

很多事情都可能导致这一点 正确缩进if .. else,运算符将sum转换为布尔值,然后与数字进行比较,汇总的数据类型不正确,然后进行比较

即使您没有使用尝试...除了并抓住它