Creating a new dictionary in Python

leora picture leora · Dec 8, 2011 · Viewed 765.7k times · Source

I want to build a dictionary in Python. However, all the examples that I see are instantiating a dictionary from a list, etc . ..

How do I create a new empty dictionary in Python?

Answer

Jan Vorcak picture Jan Vorcak · Dec 8, 2011

Call dict with no parameters

new_dict = dict()

or simply write

new_dict = {}