I just started with python , and now I am trying to understand dictionary comprehension , but I don't get the behaviour of the following code :
data = [
{'id': 12, 'data': '01'},
{'id': 10, 'data': '05'},
{'id': 11, 'data': '07'},
]
{ d['id']:d for d in data }.values()
Output :
dict_values([{'id': 12, 'data': '01'}, {'id': 10, 'data': '05'}, {'id': 11, 'data': '07'}])
please explain the output for the mentioned code . Why it is printing 2nd key value pair of each dictionary of data i.e. 'data':'01' and so on.