Python: Finding average of a nested list

python

Solution

>>> import itertools
>>> [sum(x)/len(x) for x in itertools.izip(*a)]
[4, 5, 6]

Problem

I have a list ``` a = [[1,2,3],[4,5,6],[7,8,9]] ``` Now I want to find the average of these inner list so that ``` a = [(1+4+7)/3,(2+5+8)/3,(3+6+9)/3] ``` 'a' should not be a nested list in the end. Kindly provide an answer for the generic case

Original source