access scope of variable in for loop
<p>I have searched the SO before I post this question here and hopefully
this is not a duplicated one.</p>

<pre><code>def print_me():
    a_list = range(1, 10)
    for idx, aa in enumerate(a_list):
        pass
    print(idx)

if __name__ == '__main__' : print_me()
</code></pre>

<p>Output is as follows:</p>

<blockquote>
  <p>8</p>
</blockquote>

<p>I came from C++ world and could not figure out why <code>idx</code> is still in the scope when
the code is out side of for loop?</p>

<p>Thank you</p>
