In this post, we will see how to create an set in python.
Set is collection which contains unique elements.You can simply use set() function to create empty set in Python.
Let’s see this with the help of example.
s = set()
print("empty set s:",s)
s.add(1)
s.add(2)
s.add(1)
s.add(3)
s.add(2)
print("set s:",s)
Output:
empty set s: set()
set s: {1, 2, 3}
set s: {1, 2, 3}
That’s all about Python create empty set.