I currently have a dictionary with a numerical index as keys. I know how much values I should have in total in the dictionary and would like to add the missing keys and a null value with those keys in the dictionary. To illustrate I included this example:
dictionary = {'0' : '101',
'1' : '102',
'2' : '100',
'4' : '100.5',
'6' : '103'}
I know that I have 8 values in my dictionary and so I would like to write a function that turns the above dictionary into:
dictionary = {'0' : '101',
'1' : '102',
'2' : '100',
'3' : None,
'4' : '100.5',
'5' : None,
'6' : '103',
'7' : None}
Anyone that knows how to achieve this? Thanks in advance.