Python Practice › Set Programs › Program 11
Are two sets disjoint?
Write a Python program to check whether two sets have no items in common.
Input
{1, 2}, {3, 4}; {1, 2}, {2, 3}Output
True False
Approach
isdisjoint().
Solution
print({1, 2}.isdisjoint({3, 4}), {1, 2}.isdisjoint({2, 3}))Output
True False
Learn the concept
New to this topic? Read the lesson, then come back.