How do I get the key of an item when doing a FOR loop through a dictionary or list in Python?
<p>I am new to Python.</p>

<p>Say I have a list:</p>

<pre><code>list = ['A','B','C','D']
</code></pre>

<p>The key for each item respectively here is 0,1,2,3 - right?</p>

<p>Now I am going to loop through it with a for loop...</p>

<pre><code>for item in list:
    print item
</code></pre>

<p>That's great, I can print out my list.</p>

<p>How do I get the key here? For example being able to do:</p>

<pre><code>print key
print item
</code></pre>

<p>on each loop?</p>

<p>If this isn't possible with a list, where keys are not declared myself, is it possible with a Dictionary?</p>

<p>Thanks</p>
