Implementing for loop on a dictionary in Python
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/4123266/python-looping-seems-to-not-follow-sequence">python looping seems to not follow sequence?</a><br>
  <a href="http://stackoverflow.com/questions/4458169/in-what-order-does-python-display-dictionary-keys">In what order does python display dictionary keys?</a>  </p>
</blockquote>



<pre><code>d = {'x': 9, 'y': 10, 'z': 20}
for key in d: 
    print d[key]
</code></pre>

<p>The above code give different outputs every time I run it. Not exactly different outputs, but output in different sequence. I executed the code multiple times using Aptana 3.</p>

<p><strong>First Execution Gave: 
10
9
20</strong></p>

<p><strong>Second Execution Gave:
20
10
9</strong></p>

<p><strong>I also executed the code in an online IDE <a href="http://labs.codecademy.com" rel="nofollow">http://labs.codecademy.com</a>. There the output was always 10 9 20</strong></p>

<p>I just wanted to know why is this. Ideally it should have printed 9 10 20 every time I execute the above code. Please Explain. </p>
