I have a dictionary:
my_dict = {'A': [-1,-1,-1], 'B': [-1,-1,-1], 'C': [0,0,1]} my_list=['A','C']
I want to find the average value for "A" and "C", so the average is a new list that contains the values ββfor the dictionary keys A and C, divided by 2:
result=[(-1+0)/2, (-1+0)/2, (-1+1)/2]
ie, result=[-0.5, -0.5, 0.0]
How can I calculate the result? Please note that my_list=['A','C'] not fixed, so please do not use fixed values.
EDIT: my_list=['A','C'] is the variable passed to the function. It can be, for example, ['A', 'B', 'C']. Please think about it. I cannot use "A" and "C" explicitly in code.
source share