How to check if all elements in a tuple or list are in another?
I think you want this: ( Use all )
>>> all(i in (1,2,3,4,5) for i in (1,2))
True
You can use set.issubset
or set.issuperset
to check if every element in one tuple or list is in other.
>>> tuple1 = (1, 2)
>>> tuple2 = (1, 2, 3, 4, 5)
>>> set(tuple1).issubset(tuple2)
True
>>> set(tuple2).issuperset(tuple1)
True