The code is supposed to create a new list m
from an existing list x
.
Every element m[i]
is supposed to be the arithmetic mean of the i
element in x
, but I can't make it work in any way.
def mari(x):
m = []
i = 0
for i in range(1,len(x)):
m[i]=((sum(x[i])/i+1))
i = i+1
return m
x = [1, 2, 3, 4, 5]
print mari(x)
TypeError: 'int' object is not iterable
is what seems to prevent it from working.