Open In App

Initialize an Empty Dictionary in Python

Last Updated : 12 Apr, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report

To initialize an empty dictionary in Python, we need to create a data structure that allows us to store key-value pairs. Different ways to create an Empty Dictionary are:

  • Use of { } symbol
  • Use of dict() built-in function
  • Initialize a dictionary

Use of { } symbol

We can create an empty dictionary object by giving no elements in curly brackets in the assignment statement.

Python
d = {}

print(d)
print("Length:", len(d))
print(type(d))

Output
{}
Length: 0
<class 'dict'>

Use of dict() built-in function

Empty dictionary is also created by dict() built-in function without any arguments.

Python
d = dict()

print(d)
print("Length:",len(d))
print(type(d))

Output
{}
Length: 0
<class 'dict'>

Initialize a dictionary

This code demonstrates how to create an empty dictionary using a dictionary comprehension. It initializes d with no elements and then prints the dictionary, its length, and its type.

Python
d = {key: value for key, value in []}

print(d)
print("Length:", len(d))
print(type(d))

Output
{}
Length: 0
<class 'dict'>

Related Articles:



Next Article
Article Tags :
Practice Tags :

Similar Reads