XOR operator

Report a typo

Implement an XOR operator that can work with objects of any type.

The behaviour should be the following:

  • if the operands are both truthy or both falsy, return False,
  • if one operand is truthy and the other operand is falsy, return the truthy one (the operand itself, not True).

Write your code inside the xor() function. Your program should not read any input or call the function, your task is to implement it.

Tip: Remember some facts: the bool() function returns True if the passed argument is truthy, and False if it is falsy. What operand does the or operator return?

Write a program in Python 3
def xor(a, b):
# Write your code here
___

Create a free account to access the full topic