'''Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be:
3
4 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...
5
6 Find the sum of all the even-valued terms in the sequence which do not exceed four million.
7 '''
fib = [1,2]
total=2
while fib[len(fib)-1]<4000000:
number = fib[len(fib)-1]+fib[len(fib)-2]
fib.append(number)
if number<4000000 and number % 2:
total+=number
print total