Memory Error in Python 2.7.3
<p>I'm trying to run this program on python which simulates a mindless being going around in space and to see whether it'll reach it's target.. But I'm getting a memory error every time i run it..--</p>

<pre><code>init_posn=[0,0]
posn_final=[2,2]

obs = [[-1,1],[-1,0],[-1,1],[0,1],[1,1],[1,0],[1,-1],[0,-1]]

# algo can be improved

def obs_det(posn_x,posn_y,obs):
    for e in obs:
        if e[0]==posn_x &amp; e[1]==posn_y:
            return 1
    return 0

posn=[]
posn.append(init_posn)

def posn_progress(posn,posn_final,obs):
    i=0
    non=0
    while (non==0 | (posn[i][0]==posn_final[0] &amp; posn[i][1]==posn_final[1])):
        l=posn[i][0]
        m=posn[i][1]
        if obs_det(l,m+1,obs) == 0:
            posn.append([l,m+1])
        elif obs_det(l+1,m,obs) == 0:
            posn.append([l+1,m])
        elif obs_det(l,m-1,obs) == 0:
            posn.append([l,m-1])
        elif obs_det(l-1,m,obs) == 0:
            posn.append([l-1,m])
        else:
            non=1
        i=i+1
    if non==1:
        return 0
    else:
        return posn

print posn_progress(posn,posn_final,obs)
</code></pre>
