Maxim
Maxim

Reputation: 31

display element difference between 2 arrays

I wouldlike to show only element different between this 2 arrays :

a = [['test A', 'test B', 'test C', 'test D'], ['test E', 'test F', 'test G', 'test H'], ['test G']]
b = [['test A', 'test B'], ['test E', 'test G'], ['test I', 'test G']]

something like that :

out = [['test C', 'test D'], ['test F', 'test H'], ['test H']]

Upvotes: 0

Views: 31

Answers (1)

Błotosmętek
Błotosmętek

Reputation: 12927

out = [ list(set(x).symmetric_difference(y)) for x,y in zip(a,b)]

Is that what you wanted?

Upvotes: 1

Related Questions