0
How to find out unique elements of list1 from list2
Let's: l1 = [1,2,3,4,5] l2 = [3,4,5] output should be [1,2]
3 Réponses
+ 5
Here is a version using set() and difference():
a = [1,2,3,4,5]
b = [3,4,5]
print(set(a).difference(set(b)))
+ 2
List comprehension
a=[1,2,3,4,5]
b=[3,4,5]
print([i for i in a if i not in b])
+ 1
print( set(l1) - set(l2))