列表似乎是一个整数

2024-10-01 19:29:44 发布

您现在位置:Python中文网/ 问答频道 /正文

TypeError: 'int' object is not subscriptable

代码:

def calcPossibleMoves(grid):
    possibleMoves = []
    for x in range(9):
        if grid[x] == 0:
            possibleMoves.append(x)
    return possibleMoves

Tags: 代码inforifobjectisdefnot
1条回答
网友
1楼 · 发布于 2024-10-01 19:29:44

你的问题是grid参数;您使用订阅的唯一地方是在执行grid[x]时,因此问题出在没有显示的代码中;调用函数并提供int而不是某种序列的代码

相关问题 更多 >

    热门问题