In Python, if I run the code:
T=('A','B','C','D')
D={}
i=0
for item in T:
D[i]=item
i=i+1
Can I be sure that D will be organized as:
D = {0:'A', 1:'B', 2:'C', 3:'D'}
I know that tuples' order cannot be changed because they are immutable, but am I guaranteed that it will always be iterated in order as well?
key:value
mapping will be guaranteed to be the way you showed it though). Usecollections.OrderedDict
if you need an order preserving dictionary. – Courtroom