1d = {'key':'value'}
2print(d)
3# {'key': 'value'}
4d['mynewkey'] = 'mynewvalue'
5print(d)
6# {'mynewkey': 'mynewvalue', 'key': 'value'}
7
1# Basic syntax:
2dictionary['new_key'] = value
3
4# Example:
5d = {'a': 1, 'b': 5} # Define dictionary
6d['c'] = 37 # Add a new key to the dictionary
7print(d)
8--> {'a': 1, 'b': 5, 'c': 37}
1diction = {'key':'value'}#Adding a dictionary called diction.
2print(diction)
3diction['newkey']='newvalue'#Adding the newkey key to diction with its value.
4print(diction)
5#output: {'key':'value','newkey':'newvalue'}
1# Init the dictionary
2d = {}
3# Add pairs
4key = "Foo"
5value = "Bar"
6d[key] = value
7# or
8d['What_ever_key'] = 'What_ever_value'