I have this list:
laboratorio= [ [’pol’, (’hematies’, 4430000), (’basofils’, 0.5), (’calci’,
9)],
[’josep’, (’hematies’, 5130000), (’hematocrit’, 40)],
[’enrica’, (’hematies’, 4800000), (’calci’, 11.2), (’colesterol’, 2.3)],
[’paco’, (’calci’, 10.6), (’glucosa’, 0.9)],
[’lidia’, (’hematies’, 4620000), (’hematocrit’, 50), (’basofils’, 0.7)],
[’pau’, (’calci’, 10.1), (’glucosa’, 1.5), (’colesterol’, 2.5)] ]
From this list I need to create a dictionary that the key is the name of the test and the value a list, that is, from the list above I have to create a dictionary that fits me like this:
{’colesterol’: [2.3, 2.5], ’hematocrit’: [40.0, 50.0],
’calci’: [9, 11.2, 10.6, 10.1],
’hematies’: [4430000.0, 5130000.0, 4800000.0, 4620000.0],
’glucosa’: [0.9, 1.5], ’basofils’: [0.5, 0.7]}
I made this loop:
for i in laboratori:
x=i[1:3]
What results in this:
How do I get the dictionary to stay the way they ask me?