I have two srtings of integer a=[-1,0,-1,0,1] and b=[1] and i want to subtract b from a as elementwise operation but the answer shoud be string contaning element -1 or 0 or 1
+1
A:
Maybe you mean this:
def elementwise_subtraction_of_srtings_of_integer(a, b):
c = b * (len(a) // len(b))
return [aa - bb for aa, bb in zip(a, c)]
if __name__ == '__main__':
a=[-1,0,-1,0,1]
b=[1]
print elementwise_subtraction_of_srtings_of_integer(a, b)
It produces this:
[-2, -1, -2, -1, 0]
If this is not what you want, please rephrase the question as several commenters have suggested.
hughdbrown
2009-10-30 03:54:26