I want to remove the list data type for integers values inside a dictionary in python.
Below is the input dictionary :
input_dictionary = {'key1': [21477], 'key2': [92], 'key3': [92], 'key4': [197], 'key5': [197]}
expected output_dictionary = {'key1': 21477, 'key2': 92, 'key3': 92, 'key4': 197, 'key5': 197}
How to frame the python code in order to get expected output_dictionary as below :
{'key1': 21477, 'key2': 92, 'key3': 92, 'key4': 197, 'key5': 197}
Thanking you in advance for your help.
You can do so in a simple dict comprehension:
output = {k: v[0] for k, v in input_dictionary.items()}