quit impressive to do it without the
| bitwise operator. Great challenge by the exercise, don't you think?
personally i would change this:
if (i == "0" and n[j] == "1") or (i == "1" and n[j] == "0") or (i == "1" and n[j] == "1"):
there are 4 possible cases, you written 3 of them here, you could reverse it? check if
n[j] both equal zero, if so, add 0 to k,
else add one
you could also use zip:
for i, j in zip(m,n):
print i, j
this allows you to loop over two list/strings at the same time.
you can take the slice at string conversion:
m = str(bin(m))[2:]
the purpose of the slice is to cut off
0b but i would add it at the end again:
print "0b" + "".join(k)
if you then enter 14 and 5, the exercise will approve.
@karray, this was an additional challenge from the exercise:
Try to do it on your own without using the | operator if you can help it.
of course you can do it with
|, but writing the program without is a great challenge for your coding skill