Defining a dictionary using curly braces and a list of key-value pairs is fine if you know all the keys and values in advance. But what if you want to build a dictionary on the fly?
You can start by creating an empty dictionary, which is specified by empty curly braces. Then you can add new keys and values one at a time. Once the dictionary is created in this way, its values are accessed the same way as any other dictionary. Retrieving the values in the sublist or subdictionary requires an additional index or key.
You can use dictionaries for a wide range of purposes because there are so few limitations on the keys and values that are allowed. But there are some, as you’ll see in the next lesson.
Minh Pham on March 22, 2020
Hello Paul,
Could you please provide text of what your wrote in the video so that we can try it out ourselves
BR Minh