Set Data Type

Moderator: ramajayam

Post Reply
ramajayam
Posts: 10
Joined: Wed Feb 07, 2024 8:28 am

Set Data Type

Post by ramajayam »

Set:

A Set in Python programming is an unordered collection data type that is iterable, mutable and has no duplicate elements. The most common associated method of sets are set(), add(), update(), remove(), pop(), discard(), clear(), intersection(), union(), set_difference() etc.
Example: myset = set(["a", "b", "c"])


The major advantage of using a set, as opposed to a list, is that it has a highly optimized method for checking whether a specific element is contained in the set. This is based on a data structure known as a hash table. Since sets are unordered, we cannot access items using indexes as we do in lists.
Post Reply