Python“int”对象不可在For循环上调用

2024-04-26 00:13:48 发布

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

我知道有很多这样的问题,但我看了之后,没能解决我的问题。我还在学习Python,所以可能会发生一个简单的混淆。在

到目前为止,误差是通过构造的for循环到达的。在

        # down
        column = 2
        grid = [ 10, 10 ]
        while range > 0:
            # grab at the top
            cur = genes[((grid[1] - 1) * grid[0]) + column]
            prev = cur
            for a in range((grid[1] - 2), -1, -1):
                # start one below from the top
                cur = genes[(a * grid[0]) + column]
                genes[(a * grid[0]) + column] = prev
                prev = cur
            # now apply the change back to the top
            genes[((grid[1] - 1) * grid[0]) + column] = prev
            if get_fitness(genes, grid) > fitness:
                print("After Down")
                board = Board(genes, grid)
                board.print()
                print("-------------------")
                return
            range -= 1

按要求

^{pr2}$

Tags: theboardfortoprangecolumngrid误差