 Hey, what's going on guys root of the null here, and we are looking at some more Python today We're checking out dictionaries and now dictionaries are a lot like lists But you index the values and the variables and the data and the information that you're holding within the dictionary You index them in a different way than you would a regular list because Dictionaries are kind of like associative arrays They have what we call keys that will link or associate a different piece of data with that data itself So this can sort of break your limits a little bit because it lets you like It lets you retrieve data with string sometimes and you can retrieve it with integers Just like you would a regular list, but it doesn't have to be in sequential order rather than being like indexed with zero one two Three four you could have in completely arbitrary orders You could skip around from like three to six to maybe twenty one twenty nine or something it doesn't matter You have all these ways of indexing your data, and it's in a completely different form though But you have to understand that because you're you're changing with the order of things You can't really loop through them because you don't have an ordered list It's it's unordered with keys that are usually string variables And then you have information that might not go anywhere along in that context But let's take a look at an idle. I'm gonna get started I don't plan on creating a new script or anything with these because these are pretty simple and I just don't see Too much use for them I had worked with dictionaries at one point because I think I was trying to set up like a a question and answer program And I had stored like the question as the key and the answer as the value or something like that So I would display the The question and then I think if they type in something that was the correct answer It would just realize that that's the correct answer I don't remember too much of how I did that but I realized there was a problem with the way I was doing it and It's been so long now that I don't exactly remember what it is and I but what I did is I ended up using two different lists And sort of packaging them together with by using a list inside of an instance inside of a list But I don't know that that's a whole nother topic, but let's get started with dictionaries I'll show you guys what we're doing here. I'm gonna create a new variable. I'm gonna name this a dictionary Just so you guys are able to understand what's happening here and you denote things with a bracket and Here you're gonna set up your key first of all, and I'm just gonna call this Key one and then we can change this to and we use a colon The colon is going to denote what this key will actually link to or represent or associate with When you look up key one in the dictionary, it will return this value and we'll just use like 27 or something and now it's just like a list and that you can have as many values and variables as you want to and You can add and add things to them and that sort of thing. So let's do another one key one I'm sorry key two. I don't know what I'm saying here It's it's late at night people It isn't really I'm just silly and we'll do this maybe 10 and then we'll have a completely random one just like Rubarb pi I don't think I even spelled that right. I don't know and rhubarb pi can just be 9,000 and 187 or something because who doesn't want 9,187 rhubarb pies But yeah, here we go. We got our dictionary set if we we just return this and the interpreter we get Exactly what we typed out key two is more as 10. He won is 27 rhubarb pies 9187 Now this is an interesting see interesting thing check it out that the value has been sorted 10 is first year 27 is Is next so it's looking at key to first and then key one and the reason it's doing this is because it isn't in a Specific order it automatically tries to think of it as sorted by value But we don't have to even be doing this we can use dictionaries that have Numbers for their keys you can use four Actually before we before we jump into that We'll try it and there's a in a different variable dictionary to And we use like four is equal to Four let's use the actual letter typed out name. We can have like nine can be nine can be nine and Then we'll have one as one just to see if it'll sort this So now we have dictionary two Let's see what we got here nine is nine four is four and then we have one is one. So now it's Setting it up again except it's using keys in descending order Or something I don't know it's interesting the way that Python sets this up But since we're indexing it with whatever we choose to we can use a dictionary If we try dictionary to dictionary two is we're gonna be looking at for now if we tried using four It's gonna give us an error because there is no key error There is no key titled for but there is a value titled for so we can use dictionary To and it'll index it with key four and now we get four as a string If we go back to the regular dictionary that we just created the first one if we we index it with key one We get 27 just like we had defined up here But see this does kind of ruin a little bit of structure for us though because we can't Loop through this. So this is why I don't see too much Logic in or at least too much reason for using dictionaries I guess their time can arise But if you're ever trying to process a multiple things you might want to you might have to be able to loop through it And that's why I myself prefer lists and just manipulating them in any way any way shape or form But if we do let's say a dictionary, I'm curious whether we can add things on let's try Let's try ten Equal to ten So now we have a dictionary to let's add a dictionary to it and see what happens No, it's not gonna work for dict dictionary types hmm I'm curious some of the functions that we can have with dictionaries if you if you have any object And then you put a period so you can look at there You can look at their local functions and that sort of thing if you just hit control space You have that auto come auto. Um, let's see. What am I thinking that auto complete feature? And then you can look through some of the functions that we're going to be getting into more detail later on Now another interesting thing is you can test with this of course just like you would be able to do in a um In what am I thinking a list or string or that sort of thing if you wanted to do if let's say four Is in dictionary two We can print Found it Now I want to see what'll happen here. Okay. It's not going to do anything because It's only looking in keys for the moment if we do four in If we do just regular four We print found it. It'll say found it because four as a key is in there I wonder if we can use uh if four In dictionary two Dot uh Iter values Let's give it a go and it finds it because it's it's going to iterate or loop through the values So that's just another thing you can play with dictionaries are interesting I do recommend that you check out some of the functions you can run with these before I go to in depth with them Because I will be looking at them very soon And uh, yeah, that's that's all I got for you today Thanks for watching guys. Uh, I hope you can give this video a like and be honest about it I hope maybe you can uh, maybe you can leave a comment telling what you think what you recommend What you uh, what you liked about this video what you didn't like Some things that you might wish I would do when I'm recording when I'm making these videos and that sort of thing But uh, but hey, uh, it'd be cool if you could uh, maybe subscribe. Maybe maybe uh, maybe uh, do your thing Have a great day guys. Bye