my list is somethin similar to below: my_list = [[[1,2],[2,3],[1,0]],[[0,1],[1,2]],[[8,9],[2,3],[1,0]]] so, here I am expecting my resulted list is sum of elements divided by all elements from , above list my expected output is: res = [[1.3333,1.6667],[0.5,1],[3.6667,4]]
'''
my_list = [[[1,2],[2,3],[1,0]],[[0,1],[1,2]],[[8,9],[2,3],[1,0]]]
res = [[0,0,0],[0,0,0],[0,0,0]]
for j in range(len(my_list[0])):
tmp = 0
for i in range(len(my_list[j])):
tmp = tmp + my_list[i][j]
res[j] = tmp / len(my_list)
''' tried above but not working.
my_listbecomingl1in the code. Why is the expected output not[[1.5, 2.5, 0.5], [0.5, 1.5], [8.5, 2.5, 0.5]]?