I'm trying to design a function that will sum up every row in a table. There are no headers, only rows.
So, if the function was func([[0.2,0.1],[-0.2,0.1],[0.2,-0.1],[-0.2,-0.1]]) it would return [0.3, -0.1, 0.1, -0.3]
So I'm trying to use a nested for loop that will loop over the rows, then the columns, add the values in each row together, and then put that one value in a new list as a new row.
This code below is failing and I've tried numerous iterations of it. I think my problem has something to do with needing to provide an index of where to put the new values but I'm not sure.
numrows=len(table)
numcols=len(table[0])
result= []
for m in range(numrows):
row=0.00
for n in range(numcols):
row=row+n
row.append(table[n][m])
result.append(row)
return result