This =
(assignment) assignment operator assigns a value to the variable(s).
A = B
Here,
Note: Assignment operation =
always works from right to left. The object that was referenced by the variable prior to the assignment is now dereferenced.
>>> a = 10
>>> a = 5
>>> a
5
>>> a = b = c = 10
>>> a
10
>>> b
10
>>> c
10
Here, first, value 10 is assigned to the variable c, then the value of c is to b, and the value of b is assigned to c. After evaluation, all variables refer to the same object 10.
>>> a, b, c = 1, 2, 3 # <- this is a tuple
>>> a
1
>>> b
2
>>> c
3
Here, with the right-to-left rule, a tuple containing (1, 2, 3) is created, then it is iterated and its consequent values are assigned to the comma-separated list of variables on the left.
>>> a = 0
>>> b = 1
>>> a, b = b, a
>>> a
1
>>> b
0
>>> a = 10
>>> b = 5
>>> a, b = a + b, a * b
>>> a
15
>>> b
50
Another case:
>>> a = 10
>>> b = 5
>>> a = a + b
>>> b = a * b
>>> a
15
>>> b
75