A.issuperset(B) returns True when every element of B is present in A. The method can test another iterable; for set-to-set comparisons you can also use A >= B.
For the reverse relationship, use issubset(). To test for no shared elements, use isdisjoint().
A={'x','y','z','a','b','c'}
B={'x','y','z'}
print(A.issuperset(B))
Output ( All elements of B is present in inside A )
True
A={'x','y','z','a','b','c'}
B={'x','y','z','k','l','m'}
print(A.issuperset(B))
Output ( There are elements in B which are not in A )
False
A={'y','t','W','o','e'}
B='We'
print(A.issuperset(B))
Output ( here all elements of B is present in A )
True
A={'x','y','a','b'}
B=['a','b']
print(A.issuperset(B))
Output ( all elements of B is present inside A )
True
All Set Methods Subset / Superset / Disjoint Questions with solutions on set
isdisjoint()
issubset()
Author & Instructor at plus2net
I write and maintain practical tutorials on Python, PHP, SQL, JavaScript, HTML, jQuery, and web development at plus2net. The tutorials focus on clear explanations, working examples, and code that readers can test and adapt while learning.