Python - index out of range on large initialized list
<p>I'm a beginner at Python and I'm getting a strange out of bounds error.</p>

<p>The idea is that I need a cache initialized using:</p>

<pre><code>arr = [0]*1000000
</code></pre>

<p>then accessed in the same function by calling </p>

<pre><code>def func (i) :
    k=1
    a = i
    arr = [0]*1000000
    while (i&gt;1):    
        if arr[i] != 0:
            k = k + arr[i] - 1
            break
        if i%2 == 0:
            i = i/2
        else:
            i = 3*i + 1
        k += 1
    arr[a] = k
    return k
</code></pre>

<p>if the value i is over 1500 it gives me an out of bounds error. The cache, however, is supposed to be initialized to a million ints. Am I missing something?  Thanks</p>
