What if tosumup[i] = [0, 0, 0] ? Then zeros[i] would be 3 i suppose (you don't mention how it is filled). And then the
So it is best to always test exactly what you need to check, namely: (len(tosumup[i]) - (zeros[i])) must not be 0.
if
statement would execute the next line. Which would raise the error you got.So it is best to always test exactly what you need to check, namely: (len(tosumup[i]) - (zeros[i])) must not be 0.
if (len(tosumup[i]) - (zeros[i])) != 0: a = sums[i]/(len(tosumup[i]) - (zeros[i])) else a = None # I think you need to match the indexes later, so you should add someting. avareges.append(a)