Hi tutor list,

In dictionaries, I know that the keys are immutable, and the values
can change  What about the place/order of the key/order?  I thought
that they were sequential and they do not change.


>>> D={"AAA":1234,"BBB":3456,"CCC":7890}
>>> print D
{'AAA': 1234, 'BBB': 3456, 'CCC': 7890}
>>> D={}
>>> D={"AAA":1234,"BBB":3456,"CCC":7890,"DDD":5555,"EEE":6666,"FFF": 7777}
>>> print D
{'AAA': 1234, 'BBB': 3456, 'EEE': 6666, 'FFF': 7777, 'CCC': 7890, 'DDD': 5555}

If I know the key, then I can find the value, so the order it is in the dictionary should not matter. I am just curious why this happens. If I have (4) key/value pairs, the display order is the same as I entered the them. With 5 or more key/value
dictionaries, the printed result is not sequential.

Any thoughts?

Steve
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to