1
I made a function in Python that in theory should return a and
of each element of two variables, however the result is not being expected.
The answer would be [0, 1, 0, 0, 1, 1, 0, 0]
, but is returning [0, 1, 1, 0, 1, 1, 0, 0]
, which is the value of b
a = "11001100"
b = "01101100"
def p_and(a,b):
aux=[]
for i in range(8):
aux.append(int(a[i] and b[i]))
return aux
map(int, format(int(a, 2) & int(b, 2), 'b'))
– sbrubes