I have a dictionary with one key and many values for each key:
d={'POU': ['GL', '1', '999', '4646']
'TSA': ['LA', '2', '888', '4545']
'RAS': ['NA', '5', '565', '1316']
'TSO': ['RA', '7', '575', '1376']}
The second value from each key represents distance(1, 2, 5, 7) in km. And the keys are sorted according to distance.
I want to compare the distance of the following key and discard the keys that are close to each other and have a distance equal or less than 1km. So the final dictionary will be:
d={'POU': ['GL', '1', '999', '4646']
'RAS': ['NA', '5', '565', '1316']
'TSO': ['RA', '7', '575', '1376']}
How can this be done?
What I ve managed to do so far is only to limit the keys according to distance, like:
if (float(d[key][1])<10):
but I can not make it comparing the values of each key with the following one. I am noob with python and I ve been getting crazy with it the last two days.