I'm trying to create a dictionary where the indices are a mix of strings ('20' & '0') and integers (10 & 11) but every time the dictionary is printed out the output seems to change randomly. I've read that dictionaries in python are supposed to maintain the order of the elements inserted to the dictionary, so why does this shuffling of the elements occur?
arr = {};
arr['20'] = "hello"
arr['0'] = "hey"
arr[10] = "hi"
arr[11] = "yo"
print(arr)
I would expect the output to be:
{'20: 'hello', '0': 'hey', 10: 'hi', 11: 'yo'}
but the output ends up reordering each element in the array and converting 10 & 11 into strings:
{'20': 'hello', 10: 'hi', 11: 'yo', '0': 'hey'}