Is the order of dict initialization guaranteed to happen in code order?

You guys are getting things confused.

Even in unordered dicts you would STILL get the SAME VALUES associated with the SAME KEYS.

Insertion order is irrelevant as to how python will read the function calls.

Literally just test this in python 2 and it works:

from string import ascii_lowercase
import random

random.seed(1)
COUNT = 0

d = dict(zip(ascii_lowercase, (random.random() for _ in range(26))))
print(d)

d2 = {'a': random.random(), 'b': random.random(), 'c': random.random(), 'd': random.random()}
print(d2)

python2 replit in case you don't have python2 in hand:

https://repl.it/languages/python

You will end up with the same number in the same keys, regardless of being unordered (old python) or not (new python).

/r/learnpython Thread