0

我正在做这个项目,在那里我检查一个完成的井字游戏。用户在每行(有 3 行)中输入 x 和 o 以及句点(最多 3 个)的组合。我必须检查 x 或 o 是否转了太多圈。这就是我所拥有的:

if ttt.count(x) > 5:
                    print("x took too many turns")

这仅适用于 x。当我运行程序并测试以查看此语句是否针对 x 出现时,但什么也没有出现。我究竟做错了什么?

这是一个示例运行:

0 - check a finished tic-tac-toe
1 - check a finished sudoku
2 - check a game of connect four
3 - quit
choose an option: 0
option 0
For each row, start with x. Enter a combination of x'sand o's up to three characters. For a blank space,enter a period '.'.
top row:xox
middle row:xox
bottom row:xox  
['xox', 'xox', 'xox']
0 - check a finished tic-tac-toe
1 - check a finished sudoku
2 - check a game of connect four
3 - quit
choose an option: 

这是代码的较大部分:

for x in i:
            if x not in valid_symbols:
                    print("invalid board - invalid symbol " + x )
                    done = True
                    break
            if ttt.count(x) > 5:
                print("x took too many turns")

如果我插入一个无效符号,那么它会打印该语句。

4

0 回答 0