By nature, python dictionaries have no set order - even if you have defined you dictionary in a specific order, this order is not stored (or remembered) anywhere. If you want to maintain dictionary order, you can use an OrderedDict
:
from collections import OrderedDict
identifiers = OrderedDict([
("id", "8888"), #1st element is the key and 2nd element is the value associated with that key
("identifier", "7777")
])
for i in range(1, 2):
identifiers['id'] = "{}".format(i)
for key, value in identifiers.items(): #simpler method to output dictionary values
print key, value
This way, the dictionary you have created operates exactly like a normal python dictionary, except the order in which key-value pairs were inserted (or to be inserted) is remembered. Updating values in the dictionary will not affect the order of the key-value pairs.