def average_list(M):
'''(list of list of int) -> list of float
Return a list of floats where each float is the average of
the corresponding list in the given list of lists.
>>> average_list([[4, 6], [5, 5]])
[5.0, 5.0]
'''
L = []
for item in M:
for i in range(len(item)):
avg = sum(item[i])/len(item[i])
L.append(avg)
return L
error: average_list([[4, 6], [5, 5]]) Traceback (most recent call last): avg = sum(item[i])/len(item[i]) builtins.TypeError: 'int' object is not iterable
I want to know how to fix it, thanks a lot! And any other way to do in while loop?