1address = "123 north anywhere street"
2
3for word, initial in {"NORTH":"N", "SOUTH":"S" }.items():
4 address = address.replace(word.lower(), initial)
5print address
1a_dict = {"a": 1, "B": 2, "C": 3}
2
3new_key = "A"
4old_key = "a"
5a_dict[new_key] = a_dict.pop(old_key)
6
7print(a_dict)
8OUTPUT
9{'B': 2, 'C': 3, 'A': 1}
1>>> dictionary = { 1: 'one', 2:'two', 3:'three' }
2>>> dictionary['ONE'] = dictionary.pop(1)
3>>> dictionary
4{2: 'two', 3: 'three', 'ONE': 'one'}
5>>> dictionary['ONE'] = dictionary.pop(1)
6Traceback (most recent call last):
7 File "<input>", line 1, in <module>
8KeyError: 1