I am quite new to Python and want to know how to convert the below key->value pair dictionary to key-> [value] i.e my value is a list so that I can append more elements to the list. My dictionary is as follows:
{'Mississippi': '28', 'Oklahoma': '40', 'Delaware': '10', 'Minnesota': '27', 'Illinois': '17', 'Arkansas': '05', 'New Mexico': '35', 'Indiana': '18', 'Maryland': '24'}
How can I convert to:
{'Mississippi': ['28'], 'Oklahoma': ['40'], 'Delaware': ['10'], 'Minnesota': ['27'], 'Illinois': ['17'], 'Arkansas': ['05'], 'New Mexico': ['35'], 'Indiana': ['18'], 'Maryland': ['24']}
So I tried to do this:
dict_cntrycodes= {k: [v] for k,[v] in cntry_codes}
But I am gettin ERROR: Too many values to unpack.
Any suggestions?