
![]() | Making a dictionary:
a = {'key1': 'some value', 'key2': 4.1}
a['key1'] = 'another string value'
a['key2'] = [0, 1] # change value from float to string
a['another key'] = 1.1E+7 # add a new (key,value) pair
|
![]() | Important: no natural sequence of (key,value) pairs! |
![]() | Traversing dictionaries:
for key in some_dict:
# process key and corresponding value in some_dict[key]
|