Python set issuperset() Method

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().

Set order: sets are unordered. Whenever an example prints a set, the displayed element order can differ between runs or Python environments.
issuperset True
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
issuperset False
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

Using a String

String is an iterable objects
A={'y','t','W','o','e'}
B='We'
print(A.issuperset(B))
Output ( here all elements of B is present in A )
True

Using a List

List is an iterable objects
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()


Subscribe to our YouTube Channel here



plus2net.com







Python Video Tutorials
Python SQLite Video Tutorials
Python MySQL Video Tutorials
Python Tkinter Video Tutorials
✖
We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles Contact us
© 2000-2026 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer