I want to print out the unsorted dictionary, but it came out sorted.
This is the code I use (Version 2.7.5 Linux):
# id and name array are not the actual input. It is just a sample input. (So no hard-coding please)
# More importantly, I just want to figure out how to have the unsorted dictionary.
id = [1 ,4, 2]
name = ["John" , "Mary", "Alice"]
my_dict = {}
for x in range(len(id)):
my_dict[id[x]] = name[x]
for key, val in my_dict.items():
print(key, val)
Expected Output:
(1, "John")
(4, "Mary")
(2, "Alice")
Actual Output:
(1, "John")
(2, "Alice")
(4, "Mary")