Looking for some help with this project Euler question: By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the even-valued terms.
I am sure there are other, simpler ways to do this but I am just starting out! I have managed to get the code to output the sum of the even terms of the fibonacci sequence, but I have no idea how to set the output limit to four million (I have just set the range 1 - 10 for testing). Is there anyway to do this with the current code I have written, rather than starting again?
def fibonacci(n):
if n==0:
return 0
elif n==1 or n==2:
return 1
elif n>2:
return (fibonacci(n-1)+fibonacci(n-2))
fib_list=[fibonacci(n) for n in range (1, 10) if fibonacci(n)%2==0]
fib_even=sum(fib_list)
print(fib_list)
print(fib_even)