"""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:

1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...

By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the even-valued terms."""


def recur_fibo(n):
   if n <= 1:
       return n
   else:
       return(recur_fibo(n-1) + recur_fibo(n-2))
iterations = 35
iter_list = range(iterations)
terms = []
x = 0
while True:
   for i in iter_list:
      b = (recur_fibo(i))
      if b >= 4000000:
         print "Breaking While, because b={}".format(b)
         for i in terms:
            x += i
         print "Sum of the even terms: {}".format(x)
         break
      if b % 2 == 0:
         terms.append(b)
      if i == iter_list[-1]:
         print "End of list!"
         break
   print terms
   break
