I have error " 'float' object is not iterable"?

it is necessary to calculate the sum of the first column

data = [[1.2,5.5,3.3],[2.2,4.4,7.7]]
for i in range(len(data)):
 size = sum(data[i][0])
 print(size)


Python throws the error 'float' object is not iterable
March 23rd 20 at 19:31
1 answer
March 23rd 20 at 19:33
Solution
data = [[1.2,5.5,3.3],[2.2,4.4,7.7]]
size = sum(row[0] for row in data)
print(size)

Find more questions by tags Python