Empty set in Python | Example code

Use the set() function without any arguments to create an empty set in python. Don’t use empty curly braces ” {} ” otherwise it will get an empty dictionary.

Example empty set in Python

Simple example code. An empty set does not contain any elements.

empty_set = set()

print(empty_set)
print(type(empty_set))

Output: will appear as a “ <class ‘set’> ”.

Empty set in Python

Do comment if you have any doubts and suggestions on this Python set basic tutorial.

Note: IDE: PyCharm 2021.1.3 (Community Edition)

Windows 10

Python 3.7

All Python Examples are in Python 3, so Maybe its different from python 2 or upgraded versions.


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.