My title is not very descriptive, but it is difficult to explain it in one line. Hopefully you can see what I mean below:
Here is the dictionary:
d = {"A": [33, 333, 11, 111, 27, 272,], "B": [44, 444, 23, 233]} #every two elements in the list are considered as a pair which should be later 'retrieved' as pair.
I want to work with each key in the dictionary, go over the list (value for that key in the dictionary) and do some tests, if the test passes, then I want to recover the elements that passed with its corresponding pair. Again, here is an example below to explain what I mean (I apologise for not making it very clear yet, please bear with me):
i = 0
for key, value in d.items():
print key
score_list = value[0::2] #get every other item (i.e. 33, 11, 27) , this returns a list
highest_score_in_list = score_list[0] # gets just 33 for key 'A' and 44 for key 'B'
threshold = 0.8 * float(highest_score_in_list) # 26.4 , 35.2
for index, items in enumerate(score_list):
i += 1
id = value[1::2] # I am hoping to get the 333, 111, 222) but I am not getting what I want
if float(items) <=float(threshold):
pass
else:
print index, items, id[i]
so what I was expecting is/ desired output:
A
0 33 333
2 27 272
B
0 44 444
I haven't worked it out correctly though, I am getting an index error for the taxid[i]: What I am achieving is that the threshold check works correctly, but I think I am going wrong with the indexing, maybe the way I do the i =+1 and instead of printing the corresponding id of the pair, it can't correspond them correctly and it gives me errors.
Please comment where I need to give any further clarification, and your help is greatly appreciated. I have been trying to solve it for some time. Thank you.