Python Practice › Set Programs › Program 11

Are two sets disjoint?

EasySet Programs · 11 of 48

Write a Python program to check whether two sets have no items in common.

Advertisement
Input
{1, 2}, {3, 4}; {1, 2}, {2, 3}
Output
True False

Approach

  1. isdisjoint().

Solution

Python
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.

More set programs

← All 48 Set Programs

Leave a Comment