If statement 检查tic-tac-toe游戏python

If statement 检查tic-tac-toe游戏python,if-statement,for-loop,python-3.x,while-loop,If Statement,For Loop,Python 3.x,While Loop,我必须检查一个完成的井字游戏,我必须确保用户输入的每一行有3个符号。我很难做到这一点: for i in ttt: if i < len(3): print("invalid board - too few symbols") elif i > len(3): print("invalid board - too many symbols") els

我必须检查一个完成的井字游戏,我必须确保用户输入的每一行有3个符号。我很难做到这一点:

for i in ttt:
            if i < len(3):
                print("invalid board - too few symbols")
            elif i > len(3):
                print("invalid board - too many symbols")
            else:
                continue
ttt中的i的
:
如果ilen(3):
打印(“无效板-符号过多”)
其他:
持续
ttt是附加的行

当我运行它时,我得到这样一条消息:如果我函数len()不将int类型的值作为参数:参数可能是序列(字符串、元组或列表)或映射(字典)

在这种情况下,需要使用len()找到i的长度,并将其与整数3进行比较

资源:

len(i)<3相反