I have a default dict d
in python which contains two list in it as below:
{
'data1': [0.8409093126477928, 0.9609093126477928, 0.642217399079215, 0.577003839123445, 0.7024399719949195, 1.0739533732043967],
'data2': [0.9662666242560285, 0.9235637581239243, 0.8947656867577896, 0.9266919525550584, 1.0220039913024457]
}
In future there can be many list in in default dict like data1
, data2
, data3
, data4
etc. I need to compare the index values of default dict with each other. So for above default dict I need to check weather data1[0]->0.8409093126477928
is smaller than data2[0]->0.9662666242560285
or not and same goes for other index, and store the result of wining list index in separate list like below:
result = ['data1', 'data2', 'data1', 'data1', 'data1']
If length of any list is greater than other list, we simply need to check if the last index value is smaller than 1 or not. Like data1[5]
cannot be compared with data2[5]
because there is no value of data2[5]
thus we will simply check if data1[5]
is less than 1 or not. If its less than 1 then we will consider it and add it to result
otherwise ignore it and will not save it in result
.
To resolve this I thought, of extracting the list from default dict to separate list and then using a for loop to compare index values, but when I did print(d[0])
to print the 0th
index list, it printed out []
. Why is it printing null. How can I compare the index values as above. Please help. Thanks