How do you get the logical xor of two variables in Python? September 6, 2022 by Tarik If you’re already normalizing the inputs to booleans, then != is xor. bool(a) != bool(b)