I don't understand 13/14


Please explain me what is the mask?


Bitmasks are used for manipulating specific bits of some data.

For example, if you want to read the 4th bit only, then you would create a mask with just the 4th bit turned on and use the bitwise AND operator:

fourth_bit = some_data & 0b1000
# fourth_bit will now be 0 or 8 depending on if that bit is on in `some_data`


Thank you very much.


While correct, your answer does not necessarily pertain to 13/14, where we are asked to bit-flip a whole byte. We're not looking for an &-operation to read one specific bit of a byte, we're flipping each 0->1 and 1->0. It's an XOR exercise.

To see a bit more on how XOR works compared to AND and OR, see my explanation here.

In the case of 13/14:

a = 0b11101110
print bin(a ^ 0b11111111)

Whose output is "0b10001", which is the simplified representation of "0b00010001".