- Jan 6, 2023
- 10
Hello there,
I'm attempting to construct XOR logic in Python, but my code is failing me. I want to accept two boolean inputs from the user and then utilise logical operators to determine the XOR result. However, my code does not appear to be producing the desired results like this example from scaler. Could you please assist me in determining what is wrong?
This is my code:
Whatever values I input, the output is consistent and does not appear to be the right XOR result. Is there something I'm missing regarding logical operators or their precedence? Your assistance would be much appreciated!
I'm attempting to construct XOR logic in Python, but my code is failing me. I want to accept two boolean inputs from the user and then utilise logical operators to determine the XOR result. However, my code does not appear to be producing the desired results like this example from scaler. Could you please assist me in determining what is wrong?
This is my code:
Code:
num1 = int(input("Enter the first integer: "))
num2 = int(input("Enter the second integer: "))
# Calculate XOR
result = num1 ^ num2
print("Bitwise XOR result:", result)