Question

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

No correct solution

OTHER TIPS

Maybe you mean this:

def elementwise_subtraction_of_strings_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_strings_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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top