Python set isdisjoint() Method

A.isdisjoint(other) returns True when A and the other iterable have no elements in common. If they share at least one element, it returns False.

This is closely related to intersection(): two sets are disjoint when their intersection is empty. Compare it with issubset() and issuperset().

Set order: sets are unordered. Whenever an example prints a set, the displayed element order can differ between runs or Python environments.
isdisjoint False
A={'x','y','z'}
B={'x','b','c'}
print(A.isdisjoint(B))
Output ( 'x' is the common element among two sets A and B )
False
isdisjoint True
A={'x','y','z'}
B={'a','b','c'}
print(A.isdisjoint(B))
Output ( There is no common element among two sets A and B )
True

Using a String

String is an iterable objects
A={'x','y','z'}
B='Alex'
print(A.isdisjoint(B))
Output ( here x is the common element )
False

Using a List

List is an iterable objects
A={'x','y','z'}
B=['a','b','c']
print(A.isdisjoint(B))
Output (No common elements )
True
All Set Methods Subset / Superset / Disjoint Questions with solutions on set issubset() issuperset()


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