Create an Empty Dictionary in Python

I started coding in Python more than 10 years ago, and one of the simplest yet most efficient data structures I relied on was the dictionary.

Dictionaries in Python are flexible, fast, and perfect for storing key-value pairs. But before you can fill them with data, you often need to start with an empty one.

In this tutorial, I’ll show you different ways to create an empty dictionary in Python. I’ll explain each method with easy-to-follow examples, based on how I’ve used them in real-world projects here in the USA.

Method 1 – Use Curly Braces {}

I often start with curly braces when I know I’ll be adding values dynamically. It’s quick, clean, and a common way to create an empty dictionary is by using curly braces.

# Creating an empty dictionary using curly braces
employee_data = {}

# Example: adding key-value pairs later
employee_data["name"] = "John Doe"
employee_data["state"] = "California"
employee_data["age"] = 32

print("Employee Dictionary:", employee_data)

Output:

Employee Dictionary: {'name': 'John Doe', 'state': 'California', 'age': 32}

I have executed the above example code and added the screenshot below.

python empty dictionary

In short, curly braces are the simplest way to create an empty dictionary. They’re fast, readable, and widely used by Python developers.

Method 2 – Use Python dict() Constructor

I often use Python’s dict() method when I’m working with functions that return dictionaries, or when I want my code to look more explicit.

# Creating an empty dictionary using dict()
student_scores = dict()

# Adding values later
student_scores["Alice"] = 89
student_scores["Bob"] = 95
student_scores["Charlie"] = 78

print("Student Scores:", student_scores)

Output:

Student Scores: {'Alice': 89, 'Bob': 95, 'Charlie': 78}

I have executed the above example code and added the screenshot below.

empty dictionary python

The dict() constructor is just as effective as curly braces. It’s especially useful when you want your code to be self-explanatory.

Method 3 – Use dict.fromkeys() Method in Python

Sometimes, you want an empty dictionary but with predefined keys. For example, when I worked on a project tracking US state sales, I needed all states listed upfront with no values yet.

# List of US states (short example)
states = ["California", "Texas", "Florida"]

# Create dictionary with empty values for each state
sales_data = dict.fromkeys(states)

print("Sales Data:", sales_data)

Output:

Sales Data: {'California': None, 'Texas': None, 'Florida': None}

I have executed the above example code and added the screenshot below.

python create empty dictionary

You can even initialize them with a default value:

sales_data = dict.fromkeys(states, 0)
print("Sales Data with Defaults:", sales_data)

Output:

Sales Data with Defaults: {'California': 0, 'Texas': 0, 'Florida': 0}

fromkeys() is perfect when you already know the keys but want to assign default values later. It saves time and keeps your code organized.

Method 4 – Use Python Dictionary Comprehension

Python dictionary comprehension is powerful when you want to initialize an empty dictionary in a structured way.

# Creating an empty dictionary with comprehension
# Example: preparing a dictionary with state codes but no values yet
state_codes = ["CA", "TX", "FL", "NY"]

empty_dict = {code: None for code in state_codes}

print("Empty Dictionary with State Codes:", empty_dict)

Output:

Empty Dictionary with State Codes: {'CA': None, 'TX': None, 'FL': None, 'NY': None}

I have executed the above example code and added the screenshot below.

python empty dict

I use this approach when I want flexibility. For example, I can quickly create dictionaries for large datasets programmatically.

Check if Python Dictionary is Empty

After creating an empty dictionary, you might want to check if it’s still empty. I use this check often in real-world scripts, such as verifying if a config dictionary has been populated before running a program.

data = {}

if not data:
    print("Dictionary is empty")
else:
    print("Dictionary has values")

Output:

Dictionary is empty

A simple if not dict: check is the most efficient way to confirm emptiness. It’s clean and efficient.

Real-World Example – Store US Employee Data

Here’s a practical example combining what we learned.

# Start with an empty dictionary
employees = {}

# Add data dynamically
employees["E101"] = {"name": "Sarah", "state": "New York", "salary": 75000}
employees["E102"] = {"name": "Michael", "state": "Texas", "salary": 68000}
employees["E103"] = {"name": "Emma", "state": "California", "salary": 82000}

print("Employee Records:")
for emp_id, details in employees.items():
    print(emp_id, "->", details)

Output:

Employee Records:
E101 -> {'name': 'Sarah', 'state': 'New York', 'salary': 75000}
E102 -> {'name': 'Michael', 'state': 'Texas', 'salary': 68000}
E103 -> {'name': 'Emma', 'state': 'California', 'salary': 82000}

This is exactly how I’ve used empty dictionaries in projects to store structured employee or customer data.

Creating an empty dictionary in Python is simple, but knowing the different methods makes you more flexible as a developer.

  • Use {} for speed and simplicity.
  • Use dict() for clarity.
  • Use fromkeys() when you know the keys upfront.
  • Use comprehension when generating dictionaries dynamically.

All of these methods are useful depending on your project. Personally, I switch between them based on readability and performance needs.

You may also read:

51 Python Programs

51 PYTHON PROGRAMS PDF FREE

Download a FREE PDF (112 Pages) Containing 51 Useful Python Programs.

pyython developer roadmap

Aspiring to be a Python developer?

Download a FREE PDF on how to become a Python developer.

Let’s be friends

Be the first to know about sales and special discounts.