Python multiple assignment issue (list) [duplicate]
This question already has an answer here: Tuple unpacking order changes values assigned 4 answers >>> i = 1 >>> A = [3,4,-1,1] >>> A[A[i] - 1], A[i] = A[i], A[A[i] - 1] >>> A [3, 1, -1, 4] >>> A = [3,4,-1,1] >>> A[i], A[A[i] - 1] = A[A[i] - 1], A[i] >>> A [4, 1, -1, 1] I have question when I do assignment for multiple variables for a list. Like the example above, the assignment A[A[i] - 1], A[i] = A[i], A[A[i] - 1] is different from the assignment A[i], A[A[i] - 1] = A[A[i] - 1], A[i] I am really confused the inside calculation order in Python. Why the results are different? What's the best