一个更学术的方法是:x = [[1,3,2],[4,5,6],[7,8,9]]#stripping square bracketselementsString = ''.join( c for c in str(x) if c not in '[]' )total = 0numberOfElements = 0#converting the string numbers into intfor i in elementsString.split(','): #using int but can be also float for example i = int(i) numberOfElements += 1 total += iaverage = total/numberOfElementsprint(average)#5.0 is the answer in your case