I'm looking for a method that would allow me to check what elements are missing when comparing 2 lists. A lot like in this thread but I want to write this in NumPy Python.
import numpy as np
numbers = np.array([1,2,3,4,5,6,7,8,9])
A = np.array([2,5,6,9])
def listComplementElements(list1, list2):
storeResults = []
for i in list1:
for j in list2:
if i != j:
#write to storeResults if 2 numbers are different
storeResults.append(i)
else:
#if numebrs are equal break out of the loop
break
return storeResults
result = listComplementElements(numbers, A)
print(result) #expected result [1,3,4,7,8]
At the moment the output looks like this: [1, 1, 1, 1, 3, 3, 3, 3, 4, 4, 4, 4, 5, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9]
What am I doing wrong?