Python Forum

Full Version: exclusive bitwise OR
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi

Am using 3.6.5
I'm trying to display the result of a bitwise operation, like so:
xor = 0b0011 ^ 0b0111
print ("Example of exclusive OR - xor = 0b0011 ^ 0b0111: ".format(bin(xor)))
But nothing appears.

$ ./test_bw_or.py 
Example of exclusive OR - xor = 0b0011 ^ 0b0111: 
Can somebody help?
Hi, you are missing {}, where format will place the calculated value:
print ("Example of exclusive OR - xor = 0b0011 ^ 0b0111: {}".format(bin(xor)))