Python array indexing
<p>I am writing a code for doing some integration. But I am stuck at some point(the last two lines). As it says Index Error: Index out of bounds. What I would like to do is- each time r has a value it should write to the empty corresponding index as an increment of 1 so that it can keep track of it. Any help would be appreciated. Here is the code-</p>

<pre><code>from pylab import*
from math import*

dx = 981
dy = 1043
bx = 534.4
by = 109.5

index = zeros(shape=(1,dx+dy))
r=0
r_max=0

for i in xrange(1,dy+1):
    for j in xrange (1,dx+1):
        if i-by &gt; 0:
            theta = 180*atan(abs(j-bx)/(i-by))/pi
            if theta&lt;10:
                r = round(sqrt((j-bx)**2+(i-by)**2))
                if r&gt;0:
                    index[r]+=1
</code></pre>
