 In the previous video, we used square brackets to index into a dictionary. Another way to access a dictionary is with the get method. For example, I can say result becomes countrypop.get, and the argument will be the key that I want. Let's use France as an example. And if we print the result, there's the corresponding value. What if I give a country that doesn't exist in the dictionary, such as Andorra? When I print the result this time, I'll get the special keyword value none. If you don't like having a value of none, you can use a second argument to get that will give you an alternate value in case the key isn't found. What I'll say here is result becomes countrypop.get France, zero. If this is in the dictionary, I get its value. If not, I'll get the number zero. And there's my result. Let's do it again with Andorra, and because Andorra isn't in the dictionary, I'll get the default value of zero, which you see here. The advantage of using get instead of square brackets is that it won't give you a runtime error, but it does take a bit more effort to use. Now let's talk about traversing a dictionary. We can do it with a for loop, for country in countrypop. I'll print the country and the corresponding value in the dictionary, and there's my output. In this case, the countries happen to be in the same order that they appear in the dictionary, but there's no guarantee of this. Keys are placed in the dictionary in a way that makes it easy for Python to access them, and that may not be the same as the order in which you entered them. If it is, well, that's just good luck. Another way to traverse a dictionary is with the items method, which gives you back both the key and value as a pair. For country and population in countrypop.items, I'll print the country and the population that got returned, and I get the same output. Finally, let's look at a program that creates a dictionary from scratch. We'll have a dictionary named people. The key will be their names, and the values will be their ages. We'll have a loop that asks the user for a name, and if they haven't pressed just the enter key, we'll ask for that person's age. Then we'll add it to the dictionary with this assignment. The age, which is our value, goes into the dictionary indexed by the name. To show this process in action, we're going to print the entire dictionary. Let's run the program. We have Federico, who's 22, Sally, age 29, and you'll notice here that we have our dictionary being created on the fly. Preeti, who's age 27, and finally Adam, who's age 19. Important, if you re-enter a name, the value for that key will be updated. For example, if I enter Sally again with age 30, I don't get a second entry. Instead, I get the same entry updated. Now let's add some code to sort this dictionary into alphabetical order by name and print it out. We'll need a list of all the keys. The way we do this is we use the keys method for the dictionary. We'll say name list becomes people.keys. The result of calling this method is not a list. We have to explicitly convert it to a list so that we can use our normal list commands with it. Now that we have the list of names, the keys, we'll sort it in place and then iterate through it. For each name in the name list, we'll print the person's name is and then the value, their age, years old. Also, let me comment out this debugging statement so that it will take up less room in the output. And let's run the program. We'll enter our people again here. Federico is 22, Sally is 30, Preeti is 27, and Adam is 19. And when we're done, there are our names in alphabetical order. Those are some of the other things that you can do with dictionaries.