While watching a video explaining about a quiz I found this code snippet:
a, x = x, a
a, x = x, a
print a
print x
The video says that the end result is x
and a
swap, and if we do that again, it's going to be in the original place which doesn't change the value of any variables.
My question is, if I first time assign a
=> x
and x
=> a
, then the value of code is not going to be changed even if we do the exact same code and assign the same value for the same variable as I did just before. But why does the video explain that the value of the a
and x
are going to be swapped twice and going to get the same value before executing the statement?