
employee_emails - A list of emails that will represent the dictionary keys.It’s used to iterate over two or more iterators at the same time. Using the zip() FunctionĪn alternative way to create a nested dictionary in Python is by using the zip() function. Each of those keys has a dictionary for a value, and there’s even a third dictionary assigned to the address key.ĭictionaries aren’t ordered, so that’s why you’re seeing the data not reflecting the ordering specified in the code.

Overall, we have a dictionary with two keys (emails).

Image 1 - Nested dictionary of employees (image by author) Here’s what this nested dictionary looks like: As you can see, the dictionary value is also a dictionary: Here’s an example - the following code snippet creates a nested dictionary of employees, where employee email is set for the dictionary key, and additional information as a dictionary value. Simply assign it to a variable name, and format the entire thing as JSON. It means you don’t have to use any specific functions or libraries to create a dictionary. The first way to create a nested Python dictionary is by leveraging regular Python notation. There are many ways to create a nested dictionary, but you’ll primarily use two if you’re creating them from scratch in Python.
#ACCESS LIST OF DICTIONARIES PYTHON HOW TO#
How to Create a Nested Dictionary in Python

