我在嘗試爲我的代碼的一部分解決Project Euler Problem 11時出現此錯誤。「'generator'object is not subcriptabletable」error
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
我不得不做類型轉換,因爲它仍然是一個字符串在列表中,但我不認爲這是什麼導致的問題。
忘了提,但它在測試過程中有一段時間工作,但決定在340通過後退出到最後。
什麼是矩陣? – 2011-06-09 04:16:14
你會在哪一行發生錯誤? – 2011-06-09 04:17:22
矩陣是多維列表。我收到第5行的錯誤。 – 2011-06-09 04:30:31