Python dict insertion order: What happens when you re-add a key

Python dict insertion order: What happens when you re-add a key

Modern Python dicts remember insertion order:

d = {'a':10, 'b':20, 'c':30}
list(d)      # ['a', 'b', 'c']
d.pop('b')   # remove 'b' 
d['b'] = 99  # re-add 'b' 
list(d)      # ['a', 'c', 'b']

This applies in for loops, too!