 The next data structure that we're going to be talking about is, as you can see, something known as dictionaries. Now if we think about a traditional list for just a second, the idea behind a list and to use a big fancy $5 word is you could assume that they were something known as a numeric data structure. And all that is meaning is that we have, again, some index and that index is using numerical values to reference each element inside of that list. And if I make a new day, let's say for example that when I want to make a new day of the weekend because we all want three-day weekends, I add in that element and I do something like dot append, well, at the very bottom of my list, a new entry is going to get produced and it will have the index of seven. And likewise, if I were to remove elements from a list, well, you know, let's say for example I pop zero, I get rid of Sunday, Sunday doesn't exist anymore, sorry, people. It's not that the index zero is going to go away but every value is just, well, more like every value is just going to go up. So Wednesday for example is just going to become the element at the two index, Thursday is the new three index. Now what we're introducing today is this idea of a dictionary and the big fancy $5 word for them is an associative data structure. And the entire idea behind the difference between them is instead of an index, we're going to start using a key and the entire idea to a key is this can be anything. Any data structure that we've operated with, we can use as a key and the entire sort of philosophy still goes into play. If I want to reference, let's say for example, we're still using days as the variable to represent this, so this is all days. Now if I want to represent instead of doing something like zero, instead, I can replace that zero, that numeric value and give it something like and just to change the day, I could say something like FR and Python is going to understand, oh, you're now referring referencing a dictionary. And so let me go look up the value there. And that's exactly what you can think is if you think about a dictionary, you have sort of a word that you look up, right? And then you've got sort of the definition of that word of that word as an entry into it. And I'm not going to try and define a cat because it's a cat. One thing to take note of is your data structure or your data types for these keys, like I said, can be anything and they don't have to be the exact same thing. This is Python, so it's a little more forgiving than other languages. But that means if I want to have something that is an SU, I can if I want to use something like 10 or one as an entry, well, it's just a data type and it's just ones and zeros to Python. So it's like, oh, okay, well, you for 10, you want to use Monday or for Monday, you want to use 10 or something like 3.14, it's a float, but again, this is just ones and zeros to Python. So it works perfectly fine. So how do we build a dictionary? Well, if we think about all of the different data structures that we talk about so far in this class, the big one has been lists, and we've used square brackets to represent and create lists. Well, since that's sort of already in use, we're going to be using curly braces instead for our dictionary. And they operate very similar to if we were working off of a list. Same kind of approach if we wanted to make an empty one, we would use the open and close brackets. And then this is where there are some slight differences if I want to give any entry if I want to add an entry into my dictionary, I simply use the square brackets to say what the key is, and then what the value is. And my assumption just how I kind of think about that is they're using square here because it's very similar to the list, and it just kind of makes everything, you know, cleaner when we're dealing with interacting with the data structures. You can also build it sort of statically where you just put all the values in when you're creating the dictionary, just like we can with a list, they all get separated by nice little commas. But the big difference here is that it's not just the entry, it's not just whatever element you want, but you can see that you specify the key and a little colon to say, you know, here's the entry for this. Okay, let's build this out on the fly. So let's say, for example, just to follow my own slides, we're building an inventory for a video game. So I'll just call it in vivo to shorthand it so I don't have to type so much. But I want to create my dictionary to that it is done. And if we're thinking about, you know, the video game, depending on kind of what genre you are dealing with, you're probably dealing with either health potions or health packs, you know, pick which one your, you know, works for you if you like shoot them ups or magic, you don't like video games, think of something else. But the entire idea is I would come in. And so I'd reference once again the variable representing my data structure. And if I want to add an entry, I use the square brackets and then say what key I want to add into my dictionary. So let's go ahead and say health potions. And then we would assign it some value. So let's say it's the start of the game, you know, we just load it up and we have one they give us one to start off. As you can see, no errors are going on there. And if I take a look at my inventory, I can see, oh, I have an entry for health potions and it has the value of one. This also allows me to reference that particular value. So if I wanted to print the value or just get the value of my health potions, health, health potions, I would still treat it as if it was like a list, but instead of an index, there is no index health potions. And in fact, that's actually a great point. There is no index. So I can't say inventory at zero, right? There is no entry for the zero because remember, we can use any number we want. So I could make an entry for zero. But if I wanted to say, for example, instead of printing something, I wanted to add to it. I'm going to just do a little cheating. Say for example, since I have an entry for health potions, I can use our augmented assignment operators to add to that entry. Let's say we've gone through the level and, you know, oh, we found two health potions. So we're adding to our inventory boom. And if we take a look at our inventory one more time, you can see that we still have now we have health potions, but three. And as we're going through it, you know, where we see we get new entries of things. So inventory, like, I don't know, magic scroll, it does something. I don't know what, but we can actually assign it anything. So same kind of concept going on there doesn't have to be that this is a number. Let's say that we found a fire scroll, it does fireball or something. Well, okay, you see there's no error going on there. And if I take a look once again at my inventory, I have in this case, health potions three, and then I have an entry for magic scroll that is storing fire scroll. Now in that case, it's, you know, only gonna hold one scroll, but that's where, you know, you could use a list or another data structure or data type entirely. But in a nutshell, that's how you build a dictionary.