XOR swap algorithm in python?
- by TheMachineCharmer
I tried to implement XOR sort in python.
x,y= 10,20
x,y,x = x^y,x^y,x^y
print('%s , %s'%(x,y))
OUTPUT:
30 , 30
I am not new to python but I am unable to explain this output. It should have been 20,10.
What is going on under the hood?