In this Python tutorial, you will learn how to create an empty dictionary using dict() built-in function or curly brackets notation.
Python – Create an Empty Dictionary
To create an empty Dictionary in Python, we can use dict() built-in function with no argument passed to it or take empty curly brackets and assign it to a variable.
The syntax to crate an empty Python Dictionary using dict() function is
myDictionary = dict()
The syntax to create an empty Python Dictionary using flower brackets is
myDictionary = {}
Examples (2)
1. Create empty dictionary using dict() function
In this example, we will create an empty dictionary using dict() builtin function. We shall print the type of the object returned by dict() and print the object itself.
Python Program
myDictionary = dict()
print(type(myDictionary))
print(myDictionary)
Output
<class 'dict'>
{}
2. Create empty dictionary using curly braces
In this example, we will create an empty dictionary with empty curly brackets.
Python Program
myDictionary = {}
print(type(myDictionary))
print(myDictionary)
Output
<class 'dict'>
{}
Conclusion
In this Python Tutorial, we learned how to create an empty Python Dictionary with the help of example programs.