How to swap two numbers without using a temporary variable ? | Python3 code to swap using XOR ; Code to swap ' x ' and ' y ' x now becomes 15 ( 1111 ) ; y becomes 10 ( 1010 ) ; x becomes 5 ( 0101 )
x = 10 NEW_LINE y = 5 NEW_LINE x = x ^ y ; NEW_LINE y = x ^ y ; NEW_LINE x = x ^ y ; NEW_LINE print ( " After ▁ Swapping : ▁ x ▁ = ▁ " , x , " ▁ y ▁ = " , y ) NEW_LINE