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.
1 2 3 4 5 6 7 8 9 10 11 |
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.
Was this post helpful?
Let us know if this post was helpful. Feedbacks are monitored on daily basis. Please do provide feedback as that\'s the only way to improve.