I currently have this right now
[{'label': 'ID', 'value': '8'}, {'label': 'Document', 'value': 'Authority Visit'}]
I wanted it to be
[{'ID':'8'},{'Document':'Authority Visit'}]
Thanks for helping.
I currently have this right now
[{'label': 'ID', 'value': '8'}, {'label': 'Document', 'value': 'Authority Visit'}]
I wanted it to be
[{'ID':'8'},{'Document':'Authority Visit'}]
Thanks for helping.
You can just iterate over your list and then access both label
and values
per item:
sample_dict = [
{'label': 'ID', 'value': '8'},
{'label': 'Document', 'value': 'Authority Visit'}
]
result = [{item['label']:item['value']} for item in sample_dict]
print(result)