# When setting a variable in python, why does the order matter? [closed]

def calculate_error(m, b, point):
x_point, y_point = point
y = m*x_point + b
distance = abs(y-y_point)
return distance

print(calculate_error(2, 0, (5, 5)))



I ran the code above and it worked. But I do not understand why it doesn't work when I tried setting point = x_point, y_point instead?

• x_point, y_point is what you've used? Isn't it? – nikhilbalwani May 7 '20 at 15:47
• yes. That's is correct. – Ben May 7 '20 at 15:49
• Questions specific to python are off-topic here, unfortunately. You can try your luck at Stack Overflow. – Yuval Filmus May 7 '20 at 15:51

In most programming languages, the = operator is an assignment operator which assigns to the left the values on the right.

Sometimes there are variations on the semantics, but it rarely means equal.

Coincidentally, though, which may cause confusion, after x = y, that is, after x has been assigned the value of y, the two values are equal, denoted in many languages (including Python) with x == y.

Hence, if you write

y = 3
y = x


the program crashes because x hasn't been given a value.