Sometimes, we want to get the logical xor of two variables in Python.
In this article, we’ll look at how to get the logical xor of two variables in Python.
How to get the logical xor of two variables in Python?
To get the logical xor of two variables in Python, we can use the ^
operator.
For instance, we write
bool(a) ^ bool(b)
to return the xor result of 2 booleans with ^
.
Conclusion
To get the logical xor of two variables in Python, we can use the ^
operator.