-3

Can someone give a suitable example of the XOR Operator in Python ? I understand its definition but couldn’t implement it. So, please explain with a suitable example.

Thanks in advance

pb111
  • 37
  • 6
  • 2
    The bitwise XOR operator in python is `^` – CoolCoder Apr 30 '21 at 01:39
  • Does this answer your question? [How do you get the logical xor of two variables in Python?](https://stackoverflow.com/questions/432842/how-do-you-get-the-logical-xor-of-two-variables-in-python) – gCoh Apr 30 '21 at 01:46

1 Answers1

1

This is a fair enough implementation:

def xor(a:bool, b:bool)->bool:
    return (not a) == (b)
GabrielP
  • 777
  • 4
  • 8