Exercise:
https://www.codecademy.com/courses/learnpython3/informationals/python3reggieslinearregression
My question is regarding my code vs the solution code, mainly " x_point, y_point = point":
My solution:
def calculate_error(m, b, point):
point = [x, y]
x_point = point[x]
y_point = point[y]
yvalue = get_y(m, b, x_point)
return abs(yvalue  y_point)
Given solution:
def calculate_error(m, b, point):
x_point, y_point = point
y = m*x_point + b
distance = abs(y  y_point)
return distance

I was reading other threads about how the x_point, y_point = point is a tuple. But I still dont understand this x_point, y_point = point

Is my solution wrong that I put point as a list?
Edit: … I got stuck on the second part of the question… it kept telling me x was not defined in my first solution above point [x,y], I’m a bit confused between tuples and lists.
def calculate_all_error(m, b, points):
total = 0
for point in points:
indv_error = calculate_error(m, b, point)
total += indv_error
return total
datapoints = [(1, 1), (3, 3), (5, 5), (1, 1)]
print(calculate_all_error(1, 0, datapoints))