Shi Mu wrote: > I typed: > landUse = {'res': 1, 'com': 2, 'ind': 3, "other" :[4,5,6,7]} > and when i checked landUse, I found it become: > {'ind': 3, 'res': 1, 'other': [4, 5, 6, 7], 'com': 2} > why the order is changed?
the docs warn you about this. A dictionary stores its values based on the keys. Internally Python sorts the keys to make the lookup meet performance expectations. You can not expect a dictionary to return keys in the other you added them. If you want that, store the items as tuples in a list. landUse = [('res', 1), ('com', 2), ('ind', 3), ("other", [4,5,6,7])] _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor