13 Make sure your answer is a binary string


#1
a = 0b11101110
mask = 0b1111111
desired = a ^ mask
print bin(desired)

what rookie mistake did i make to get this error


#2
a = 0b11101110
mask = 0b1111111
print "XOR | 0 1"
print "----+----"
print "  0 | 0 1"
print "  1 | 1 0"
print format(a, '#010b') + " your a"
print format(mask, '#010b')+" your 7-bit mask"
print format(a ^ mask, '#010b') + " Result XOR"
print "=============="
desired = format(a ^ mask, "#010b")
print type(desired)
print desired

[output]

XOR | 0 1
----+----
  0 | 0 1
  1 | 1 0
0b11101110 your a
0b01111111 your 7-bit mask
0b10010001 Result XOR
==============
<type 'str'>
0b10010001

11. The man behind the mask is giving me pronlems
Bit mask
#4

sorry i mean codeblaster48566


#5

Doesn't seem to help.


#6

You are missing one digit in your mask: You wrote
mask = 0b1111111 instead of
mask = 0b11111111


#7

the code should be: see image


#8

this is my code hope it will help

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