from __future__ import print_function

# using generators here as we don't know how long we'll need to run the loop
# this creates a "stream" of fibonacci numbers that we can test for evenness

def fib(limit=4000000):
    F = []
    i = 0
    while True:
        if i > 1:
            F.append(F[i - 1] + F[i - 2])
        elif i == 0:
            F.append(1)
        elif i == 1:
            F.append(2)
        i += 1
        if F[-1] < limit:
            yield F[-1]
        else:
            return

print(sum(x for x in fib() if x % 2 == 0))

@@ -60,75 +60,17 @@
 ere 
-as we don't know how long we'll need to run the loop%0A# this
+to
  create
-s
  a %22
@@ -109,16 +109,18 @@
 t we can
+%0A#
  test fo
@@ -164,16 +164,20 @@
    F = %5B
+1, 2
 %5D%0A    i 
@@ -182,221 +182,108 @@
 i = 
-0
+2 %0A
 %0A    
-while True:%0A        if i %3E 1:%0A            F.append(F%5Bi - 1%5D + F%5Bi - 2%5D)%0A        elif i == 0:%0A            F.append(1)%0A        elif i == 1:%0A            F.append(2)%0A        i += 1%0A        if F%5B-1%5D %3C limit:%0A    
+for x in F:%0A        yield x%0A%0A    while F%5B-1%5D %3C limit:%0A        F.append(F%5Bi - 1%5D + F%5Bi - 2%5D)%0A
     
@@ -310,32 +310,14 @@
     
-else:%0A            return
+i += 1
 %0A%0Apr

simplify fib stream generation