13.flip out


Anyone explain where i need to change the code

File "python", line 3
for x in range(len(bin(a))-2):
IndentationError: unexpected indent

Oops, try again. Hey now--no changing the value of a!

a = 0b11101110
mask = ""
    for x in range(len(bin(a))-2):
        mask = mask + "1"
    print mask
    mask = int(mask,2)
    desired = a ^ mask
    print bin(desired)


Hi @systemcoder22323,

Your code raised an IndentationError because you indented everything after the first line. If you correct the indentation, your code will work.

However, you are doing more than is necessary to create the mask object.

The instructions include this ...

In the editor is the 8 bit variable a.

Since it is given that the variable has 8 bits, you can just create a mask object that has 8 bits that are all 1, without using a loop. Nevertheless, what you are doing is based on an idea that can work.


thanks I understand the indentation error type