+ 2
how to Subtract 2 lists .
eg. a=[3,4,5,7,8,3] - b=[3,4,5,7] (need a simple way)
4 ответов
+ 5
What do you mean by subtraction? Can you tell what is the expected output?
+ 5
while b:
x = b.pop()
if x in a:
a.remove(x)
# now `a` is your desired output
Edit: do you need a code snippet or is this sufficient?
+ 4
a = [3,4,5,6]
b = [3, 4]
print([i for i in a if i not in b])
#5 6
import numpy as np
a = np.array([3,4,5,6])
b = np.array([1,2,3,4])
print(a - b)
#2 2 2 2
+ 2
[8,3]