I have a list created by an iterative process consisting of a variable number of sub-lists of all of them with the same number of elements; which is also variable. For example, in one iteration, I can have 4 sublists of 3 elements each, for example:
list_1 = [[1,3,5], [7,4,9], [3,6,2], [5,4,7]]
and in the next iteration of the code, I can:
list_2 = [[2,4,8,3,5], [2,4,9,1,3], [1,9,6,3,6]]
those. 3 sublist of 5 items.
For this iteration, all the sublist letters will always have the same number of elements.
I need a way to generate for iteration i new list from list_i containing the average value of all elements located at the same position in each sublist. So in the first case for list_1 I get:
avrg_list = [4.0, 4.25, 5.75]
and in the second case for list_2 :
avrg_list = [1.67, 5.67, 7.67, 2.33, 4.67]
How can I do this with flexible code that will tune to a different number of subscriptions and items?