Python Practice › Set Programs › Program 35

Are two sets equal?

EasySet Programs · 35 of 48

Write a Python program to check whether two sets are equal.

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

Approach

  1. == compares contents; order does not matter.

Solution

Python
print({1, 2, 3} == {3, 2, 1}, {1, 2} == {1, 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