Python - Sets

Sets are used to store multiple items in a single variable. A set is a collection which is unordered, unchangeable.

Example 1: use of Sets

s = {10, 20, 15, 30}
s = {10, 20, 15, 30, 10}  # Sets does not support duplicate values

s.pop()                   # Remove the last element from the list
s.remove(15)              # Remove element, having value 15
s.add(50)                 # Add an element 50 in set
{10, 20, 15, 30}
{10, 20, 30, 15}
{10, 20, 30, 15, 50}