1# A Python program to demonstrate working of key
2# value change in OrderedDict
3from collections import OrderedDict
4
5print("Before:\n")
6od = OrderedDict()
7od['a'] = 1
8od['b'] = 2
9od['c'] = 3
10od['d'] = 4
11for key, value in od.items():
12 print(key, value)
13
14print("\nAfter:\n")
15od['c'] = 5
16for key, value in od.items():
17 print(key, value)
18"""
19Ouptut:
20Before:
21
22('a', 1)
23('b', 2)
24('c', 3)
25('d', 4)
26
27After:
28
29('a', 1)
30('b', 2)
31('c', 5)
32('d', 4)
33"""
1>>> from collections import OrderedDict
2>>> dict(OrderedDict([('method', 'constant'), ('data', '1.225')]))
3{'data': '1.225', 'method': 'constant'}