Possible Duplicate:
In what order does python display dictionary keys?
There was this very weird Python question which I was trying to answer (on SO but looks like the author deleted it). This has gotten me head-over-heels and I cannot seem to plausibly explain myself what could be the cause behind this flummoxing phenomenon. I have a Python dictionary (associative array) which I initialize as below.
d = {"word1": 1, "word2": 2, "word3": 3}
And loop through it using a for..in construct in which i print the keys of "d" separated by a space.
Expected output: word1 word2 word3
Actual output: word1 word3 word2
I then tried to print "d" as
print d
Output
{'word1': 1, 'word3': 3, 'word2': 2}
I was scanning the online Python docs, existing questionnaire on SO, blogs but fully failed to figure out the cause. Am I missing something here? Furthermore, there's a kind request to all those who down-vote this question to please elaborate on the reason for the same.
Cheers. :-)