how do we add a key and a value to a dictionary in python code example
Example 1: how to add an item to a dictionary in python
a_dictonary = {}
a_dictonary.update({"Key": "Value"})
Example 2: add key to dictionary python
d = {'key': 'value'}
print(d)
# {'key': 'value'}
d['mynewkey'] = 'mynewvalue'
print(d)
# {'key': 'value', 'mynewkey': 'mynewvalue'}