小编Mat*_*nah的帖子

"'生成器'对象不可订阅"错误

在尝试解决Project Euler Problem 11时,为什么我从代码的第5行收到此错误?

for x in matrix:
    p = 0
    for y in x:
        if p < 17:
            currentProduct = int(y) * int(x[p + 1]) * int(x[p + 2]) * int(x[p + 3])
            if currentProduct > highestProduct:
                print(currentProduct)
                highestProduct = currentProduct
        else:
                break
            p += 1
Run Code Online (Sandbox Code Playgroud)
'generator' object is not subscriptable
Run Code Online (Sandbox Code Playgroud)

python generator

33
推荐指数
1
解决办法
5万
查看次数

标签 统计

generator ×1

python ×1