i have a set of points like this:
points = [[1, 1], [2, 3]]
i want to add up the x-components and y-components separately so i wrote this code
sum_x = reduce(lambda a, b: a[0] + b[0] ,points)
sum_y = reduce(lambda a, b: a[1] + b[1], points)
if i have only 2 points it works but if i add any more points then i get this error:
Traceback (most recent call last):
File "linear-regression.py", line 29, in <module>
sum_x = reduce(lambda a, b: a[0] + b[0], points)
File "linear-regression.py", line 29, in <lambda>
sum_x = reduce(lambda a, b: a[0] + b[0], points)
TypeError: 'int' object is not subscriptable