[Solved] What does ^= do in python [closed]


^ is the binary XOR operator. In short, it converts input into binary numbers and performs a bitwise XOR operation.

>>> 2^3 # 10 XOR 11
1 # 01

The expression lone num ^= number is equivalent to

lone_num = lone_num ^ number

I’d be happy to answer any additional questions you might have.

2

solved What does ^= do in python [closed]