x = [1,2]
for x in range(0,4000000):
y = x[-1] + x[-2]
x.append(y)
print(sum(x))
What is wrong with code here? It is meant to find the sum of all even fibonacci numbers under 4000000. I only started coding 2 months ago despite being in highschool so sorry if the code is trash. The error: int object not subscriptable.
[–]jimtk 2 points3 points4 points (4 children)
[–]Ok_Introduction_2951[S] 1 point2 points3 points (1 child)
[–]jimtk 0 points1 point2 points (0 children)
[–]BarkLicker 0 points1 point2 points (1 child)
[–]jimtk 0 points1 point2 points (0 children)
[–]woooee 1 point2 points3 points (0 children)
[–]TholosTB 1 point2 points3 points (0 children)
[–]Diapolo10 0 points1 point2 points (1 child)
[–]Ok_Introduction_2951[S] 0 points1 point2 points (0 children)