I was writing code for finding sum of even-valued terms in Fibonacci sequence whose values do not exceed four million.the code works fine for values upto 40k But I got an memory error for finding upto 4 million can someone help me resolve the problem

my code is:

```
def fib(x):
    l=[0,1]
    m=[]
    a=0
    c=0
    b=1
    while len(l) <=x:
             d=c+b
             c=b
             b=d
             l.append(d)
             if d%2==0: 
                    m.append(d)
                    a=a+d
    print 
    print a 
    print m

```