r/pythonhelp • • Oct 26 '22

what does that mean ?

what does x^=3 when x=5 mean ?

it evaluates to 6

3 Upvotes

3 comments sorted by

View all comments

4

u/socal_nerdtastic Oct 26 '22

^ is the "bitwise xor" operator.

    0101 (decimal 5)
XOR 0011 (decimal 3)
  = 0110 (decimal 6)

https://en.wikipedia.org/wiki/Bitwise_operation#XOR

1

u/ab624 Oct 26 '22

cool, thanks