In Python, a Set is an unordered collection of data items that are unique. Learn to create a set and add, update, and remove items from a set. Also, learn the different set methods and operations such as union, intersection, differance, and many more.
In Python, a Set is an unordered collection of data items that are unique. In other words, Python Set is a collection of elements (Or objects) that contains no duplicate elements.
Unlike List, Python Set doesn’t maintain the order of elements, i.e., It is an unordered data set. So you cannot access elements by their index or perform insert operation using an index number.
In this tutorial, we will learn Set data structure in general, different ways of creating them, and adding, updating, and removing the Set items. We will also learn the different set operations.

Characteristics of a Set
A set is a built-in data structure in Python with three key characteristics:
- Unordered: Items in a set have no fixed order, unlike lists. When you access a set, the items may appear in different orders. Sets don't assign index values to their items.
- Unchangeable: Set items must be immutable. While you can add or remove items from a set, you cannot modify the items themselves. Though the set can be modified as a whole, each element within it must be of an immutable type.
- Unique: A set cannot contain duplicate items—each value must be unique.
Table of contents
Creating a SetCreate a set from a listCreating a set with mutable elementsEmpty setAccessing items of a setChecking if an item exists in SetFind the length of a setAdding items to a SetRemoving item(s) from a set- Set Operations
- Copying a Set
- Subset and Superset
- find whether two sets are disjoint
- Sort the set
- Using Python built-in functions for Set
- all() and any()
- max() and min()
- Frozen Set
- When to use frozenset ?
- Nested Sets
- Set comprehension
- When to use a Set Data structure?