a = [{43:123}, {3:103}, {36:103}, {2:102}, {23:100}]
How can I extract id from it when each of the keys is id and value means a number of points.
I tried use this:
for b in a:
print a[i].keys()
i+=1
Python result is a list, but I need integer type. eg
print a[2].keys() result [36] and I need 36 which is int. Thx
Access the first element from such list:
or
both returning the int
36.To get a list of all keys:
returning
[43, 3, 36, 2, 23]Maybe you should convert your list of dicts into a simple dict:
obtaining
{2: 102, 3: 103, 23: 100, 36: 103, 43: 123}, where you can get all keys with simpled.keys()and obtaining[3, 2, 43, 36, 23], although the order is not conserved.