为什么它没有给出正确的第一个甚至斐波纳契数最多达到400万的总数?
x = 1
y = 2
list = [1,2]
while y< 4000000:
z= x+y
x=y
y=z
list.append (y)
list_even = []
for a in list:
if a%2 == 0:
list_even.append (a)
else:
pass
total = sum(list_even)
print (total)
Run Code Online (Sandbox Code Playgroud) python ×1