Contents
Empty Dictionary in Python
You can create an empty dictionary in Python in many ways.
In this tutorial, we will present you examples in some of the ways to create an empty Python dictionary.
Example 1: Empty Python Dictionary using {}
You can assign empty curly braces to a variable, and the variable is initialized to a Dictionary with no key:value pairs.
Python Program
myDict = {}
print(type(myDict))
print(myDict)
Run Output
<class 'dict'>
{}
An you can see the output, empty Python dictionary is created.
Example 2: Empty Python Dictionary using dict() constructor
There is also another way of creating an empty dictionary in python. And that is using dict() constructor. Provide no arguments to dict() constructor, and it returns an empty dictionary.
Python Program
myDict = dict()
print(type(myDict))
print(myDict)
Run Output
<class 'dict'>
{}
Summary
In this tutorial of Python Examples, we learned how to create an empty dictionary using initialization and dict() constructor, with the help of well detailed examples.