I am trying to check if the list List2
is a subset of List1
in python 3.8
I tried all()
and issubset()
functions and they all fail to filter it as I wanted - they give True, unfortunately - elements of two
actually not all in one
, are they?
List1 = [1, 4, 1, 3, 5]
List2 = [1 , 1, 1]
What I tried:
check = all(item in List1 for item in List2)
failed, returns True.
flag = 0
if(set(List2).issubset(set(List1))):
flag = 1
print(flag)
failed, returns True.
Also using intersection()
gives True (actually I don't want intersection).
What is the solution for this? Have not checked Numpy
yet.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…