Turn It On!


#1

a = 0b10111011
mask = 0b10111011
desired = a | mask
print bin(desired)

error:
The correct binary string was not printed!

help me out guys!!


#2

Hi @drunkster,

The third bit from the right is the one that you need to turn on. All other bits should be the same in the result as they are in the original variable, a. Revise the mask variable so the third bit from the right, and only that bit, gets turned on if necessary, regardless of the value of the variable, a. You have some 1 bits in mask that would turn on bits other than the third bit from the right. For example, your mask would turn on the two rightmost bits, among others.

If necessary, review A BIT of This OR That.


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.