'How can I remove the same values from arrays and put the remnants in two different arrays
I have two arrays with string values, they have similar values and different ones, how can I remove the same values from them and put the remnants in two different arrays? Example from below
one_ar = ['Python', 'Java', 'C']
two_ar = ['Python', 'Lua']
one_result = ['Java', 'C']
two_result = ['Lua']
Solution 1:[1]
A simple solution would be
one_result = [x in one_ar if x not in two_ar]
two_result = [x in two_ar if x not in one_ar]
If you need it with efficient scaling to large size, you might prefer something else.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Giovanni Tardini |
