How do you get the logical xor of two variables in Python?

If you’re already normalizing the inputs to booleans, then != is xor.

bool(a) != bool(b)

Leave a Comment