I have two lists:
- with the elements:
[0.7181,7.3,561257621.7,0.12122,9.8]
- with indices:
[0,2]
How can I calculate average of elements which indices I do have in second table?
I have two lists:
[0.7181,7.3,561257621.7,0.12122,9.8]
[0,2]
How can I calculate average of elements which indices I do have in second table?
I would use:
>>> elements = [0.7181, 7.3, 561257621.7, 0.12122, 9.8]
>>> indices = [0, 2]
>>> sum([elements[i] for i in indices])/len(indices)
280628811.20905