I need to do XOR operation between two binary strings.
xor("00110011", "11001100") = "11111111"
i am currently using this function
def xor(x, y):
ans = ""
for i in xrange(len(x)):
if x[i] == "0" and y[i] == "1" or x[i] == "1" and y[i] == "0":
ans += "1"
else:
ans += "0"
return ans
please give me good method
^- the xor operator. Please see stackoverflow.com/questions/19414093/…xor('01', '00')for example? Is the output'1'or'01'. In other words, should the output be the same string length, always?