1 00:00:12,130 --> 00:00:13,810 Hi, everybody, welcome. 2 00:00:13,840 --> 00:00:21,550 So this video will console resolving the assignments of dictionaries, the advanced part. 3 00:00:22,030 --> 00:00:23,710 So let's begin more. 4 00:00:23,710 --> 00:00:28,260 Once our project is open, let's click right click on the project. 5 00:00:28,260 --> 00:00:38,000 Then you bite on and give a meaningful name, which will be collections dictionary project. 6 00:00:38,020 --> 00:00:41,800 This advanced, right? 7 00:00:49,800 --> 00:00:52,920 So this would be also, Karl. 8 00:00:55,870 --> 00:00:59,350 Lection dictionary practice. 9 00:01:00,810 --> 00:01:01,620 Advanced. 10 00:01:02,730 --> 00:01:05,160 And here I'm missing Kenny. 11 00:01:06,860 --> 00:01:09,990 All right, it's collections. 12 00:01:10,850 --> 00:01:11,210 Yeah. 13 00:01:11,840 --> 00:01:20,210 All right, so first of all, first assignment was to create a dictionary. 14 00:01:22,140 --> 00:01:22,940 Daksha. 15 00:01:25,220 --> 00:01:28,940 Wary of building attendance, right? 16 00:01:29,420 --> 00:01:31,420 So how do we do it? 17 00:01:37,420 --> 00:01:37,840 All right. 18 00:01:40,230 --> 00:01:48,330 We just do the following thing, we do curly brackets, and then here we would put, by the way, just 19 00:01:48,330 --> 00:01:52,740 a quick note and didn't remember if I already mentioned it. 20 00:01:52,740 --> 00:01:58,920 But it doesn't matter if you put a single quotation mark or a double quotation mark as long as you don't 21 00:01:58,920 --> 00:02:00,240 have one of each. 22 00:02:00,840 --> 00:02:03,510 OK, as long as they're from the same type. 23 00:02:03,510 --> 00:02:05,610 So is the same thing for Python. 24 00:02:06,450 --> 00:02:09,960 So first of all, let's create the floor first floor. 25 00:02:10,230 --> 00:02:11,610 So floor one. 26 00:02:11,880 --> 00:02:21,290 And right after we submitted the key, now we need to submit the right part, which in Nonis the cells, 27 00:02:21,420 --> 00:02:23,700 not Nestel dictionaries would be disvalue about. 28 00:02:23,880 --> 00:02:31,740 In our case, we have a nested cell here with additional key, which will be first apartment like this. 29 00:02:32,220 --> 00:02:45,810 Yeah, and here we have Rachel and then we have second apartment and how we here we have the closet. 30 00:02:46,380 --> 00:02:47,820 Here we have Gene. 31 00:02:51,170 --> 00:02:53,670 By the way, have a look right here. 32 00:02:53,720 --> 00:02:58,220 I know I've said it a single quotation mark here, I have double quotation marks. 33 00:02:58,250 --> 00:02:59,710 Everything's fine, there's no error. 34 00:02:59,990 --> 00:03:07,100 But just for the sake of order, which is going to put single in every one because I like order. 35 00:03:07,220 --> 00:03:09,070 Don't like mixed stuff here. 36 00:03:12,250 --> 00:03:19,620 OK, so we're fine and right after this, and I'm just going to put the comma here, because we have 37 00:03:19,620 --> 00:03:22,620 finished like looking in an overview. 38 00:03:22,630 --> 00:03:25,730 So this is the parent cell. 39 00:03:25,950 --> 00:03:32,120 We have the key section here and we have the sort of value here. 40 00:03:32,340 --> 00:03:34,530 And once we finished it, we put a comma. 41 00:03:34,920 --> 00:03:40,230 And because I'm close to the end of the line here, I can also go down the line using enter. 42 00:03:41,190 --> 00:03:46,590 And right here, it's more static, you know, and right here I'm going to pull floor to. 43 00:03:46,890 --> 00:03:47,280 Yeah. 44 00:03:47,280 --> 00:03:48,200 And the same thing. 45 00:03:48,210 --> 00:03:55,950 So here we have quelque curly brackets and we have here the third. 46 00:03:57,350 --> 00:03:58,520 Apartment. 47 00:04:01,860 --> 00:04:11,220 With Jack, which is Joe is the resident, so you see, like if looking at the dictionary now, it looks 48 00:04:11,220 --> 00:04:12,620 pretty complicated, right? 49 00:04:12,690 --> 00:04:18,420 How the curly brackets and then you have a key and again, curly brackets and ECOMIL, what's going 50 00:04:18,420 --> 00:04:18,860 on here? 51 00:04:19,320 --> 00:04:24,780 But if you drill down and break break it down into small pieces, if you break down the problem into 52 00:04:24,780 --> 00:04:26,900 small pieces, so it's pretty easy. 53 00:04:26,910 --> 00:04:28,470 So you have a key here. 54 00:04:28,680 --> 00:04:29,240 Correct. 55 00:04:29,940 --> 00:04:34,590 Then you have two dots and then you have the place of the value. 56 00:04:34,980 --> 00:04:40,320 But instead of the value, you just create another dictionary, just open the brackets and put another 57 00:04:40,320 --> 00:04:44,460 key of the value, comma, key value. 58 00:04:44,460 --> 00:04:45,150 Close it. 59 00:04:46,090 --> 00:04:49,920 OK, it's the same thing, always the same thing all over again. 60 00:04:50,490 --> 00:04:50,970 All right. 61 00:04:52,380 --> 00:05:00,180 Also here we have a key to that curly brackets, key and value, and then the closing brackets of the 62 00:05:00,180 --> 00:05:00,930 whole dictionary. 63 00:05:01,680 --> 00:05:04,350 All right, so let's print out the dictionary. 64 00:05:10,490 --> 00:05:19,100 Yeah, so casting and then building attendance, yeah, and let's run it there we have it. 65 00:05:19,100 --> 00:05:21,090 So we have the dictionary printed out. 66 00:05:21,590 --> 00:05:24,170 Let's head over to the second assignment now. 67 00:05:24,250 --> 00:05:41,590 We are we were asked to extract the defendants names name who lives on the first floor, second apartment. 68 00:05:41,600 --> 00:05:41,900 Right. 69 00:05:44,300 --> 00:05:54,140 So we want to extract the value of who lives, whoever lives in the first floor, in the second apartment. 70 00:05:54,410 --> 00:05:57,990 So first floor, second apartment is this girl. 71 00:05:58,400 --> 00:06:00,260 So now what we need to do. 72 00:06:01,490 --> 00:06:02,570 Oh, I'm sorry. 73 00:06:02,930 --> 00:06:03,860 I have a mistake. 74 00:06:03,950 --> 00:06:04,330 Right. 75 00:06:05,390 --> 00:06:08,900 We were asked to extract nested cell items. 76 00:06:08,900 --> 00:06:10,670 Sorry, extract. 77 00:06:12,530 --> 00:06:15,270 Nested sale items like this. 78 00:06:15,680 --> 00:06:25,220 So what we have now to do, what we need to do now is to, uh, mention the dictionary and as we did 79 00:06:25,220 --> 00:06:28,460 already, just to mention the key here. 80 00:06:28,700 --> 00:06:36,740 And then once we mention the key, all right, we could we would print out all of these items. 81 00:06:37,910 --> 00:06:44,930 OK, let's cover it with print, uh, first. 82 00:06:46,500 --> 00:06:50,190 First floor items of the dictionary. 83 00:06:54,970 --> 00:07:03,550 And string casting like this and the right click in the wrong, let's see if we were right. 84 00:07:04,810 --> 00:07:05,230 All right. 85 00:07:05,240 --> 00:07:13,010 So now we have printed out all the items which are in the first floor and these are the items here. 86 00:07:13,150 --> 00:07:14,970 So what's the logic behind it? 87 00:07:14,980 --> 00:07:21,700 You just mentioned the key and then it will give you the what what appears on the right side of the 88 00:07:21,700 --> 00:07:22,310 two dots. 89 00:07:22,870 --> 00:07:24,370 So basically, this is what we need. 90 00:07:25,480 --> 00:07:32,690 And now we have by the way, I want just want to mark here the number of the assignments. 91 00:07:32,690 --> 00:07:37,300 So it would be more clear in the print out what we're dealing with. 92 00:07:38,710 --> 00:07:45,670 And now we were asked to extract of whoever lives. 93 00:07:47,650 --> 00:07:51,400 And the second apartment, right? 94 00:07:53,640 --> 00:08:01,590 Which is gin and what we basically need to do, so let's have a look at this. 95 00:08:01,740 --> 00:08:02,190 All right. 96 00:08:02,190 --> 00:08:05,980 So let's learn from our examples right here. 97 00:08:06,000 --> 00:08:08,840 We drilled down one level. 98 00:08:09,210 --> 00:08:10,440 What do you mean one level? 99 00:08:10,590 --> 00:08:12,510 We just entered the dictionary. 100 00:08:12,750 --> 00:08:15,890 We entered it, and then we drilled down only one level. 101 00:08:15,920 --> 00:08:20,190 We just took the key and we said, hey, give me all what you have for this key. 102 00:08:21,210 --> 00:08:21,590 All right? 103 00:08:21,600 --> 00:08:24,180 But now we need to drill down twice. 104 00:08:24,180 --> 00:08:29,250 We need to take this key and afterwards to take also this key. 105 00:08:29,670 --> 00:08:39,120 OK, so we already seen an example for it in the previous video and sorry, not the previous one before 106 00:08:39,120 --> 00:08:39,300 it. 107 00:08:39,690 --> 00:08:48,180 And basically what we need to do is, again, to mention floor one here like this and right after to 108 00:08:48,180 --> 00:08:49,410 drill down one more. 109 00:08:49,620 --> 00:08:55,860 And what you need to do is to get the second apartment key like this. 110 00:08:57,580 --> 00:09:00,910 And cover it with print, obviously. 111 00:09:06,050 --> 00:09:15,140 Brent of the then then and the second apartment like this. 112 00:09:18,260 --> 00:09:20,180 And this is assignment number three. 113 00:09:21,890 --> 00:09:28,820 All right, so we have some malfunction here, we missed the plus side, of course. 114 00:09:29,430 --> 00:09:30,550 Let's run it. 115 00:09:30,650 --> 00:09:33,230 What we expecting to see is Ginne, obviously. 116 00:09:34,950 --> 00:09:36,350 OK, there you ha. 117 00:09:36,350 --> 00:09:37,130 There we have it. 118 00:09:37,490 --> 00:09:38,210 We see Jeanne. 119 00:09:38,450 --> 00:09:46,130 So we drill down once here with this key and then we drilled down twice with this key. 120 00:09:46,130 --> 00:09:49,010 And then we get the gin, then we get the resident. 121 00:09:49,410 --> 00:09:50,000 All right. 122 00:09:50,630 --> 00:10:01,060 So the assignment number four was to add a fourth apartment to the dictionary in floor two. 123 00:10:01,520 --> 00:10:01,910 All right. 124 00:10:01,910 --> 00:10:07,190 So add a fourth apartment on floor two. 125 00:10:08,150 --> 00:10:09,510 And how do we do it? 126 00:10:09,890 --> 00:10:12,130 Basically, we want to put Carol there. 127 00:10:12,350 --> 00:10:21,050 So we mention the dictionary and then we mention the first key that we want to access, which is for 128 00:10:21,060 --> 00:10:21,440 two. 129 00:10:21,770 --> 00:10:29,450 And then we mentioned the second key, which is not existing at the moment, which is apartment four. 130 00:10:30,230 --> 00:10:35,120 And then we put the equals and we put Carol inside the place that we want. 131 00:10:35,120 --> 00:10:40,820 We want to put her in the key number, first key, which will be four two. 132 00:10:40,940 --> 00:10:44,840 And then we want another key or floor number for. 133 00:10:45,020 --> 00:10:45,450 All right. 134 00:10:45,470 --> 00:10:47,450 Like, we have third apartment. 135 00:10:47,660 --> 00:10:49,700 We want to put it here, inside here. 136 00:10:49,700 --> 00:10:57,060 So maybe it's better to put it like fourth apartment because it's all letters here. 137 00:10:57,110 --> 00:10:57,750 No numbers. 138 00:10:58,190 --> 00:10:58,550 All right. 139 00:10:58,560 --> 00:11:00,130 So this is the second drill down. 140 00:11:00,380 --> 00:11:01,010 Let's run it. 141 00:11:03,410 --> 00:11:05,510 Oh, I did it printed, of course. 142 00:11:26,730 --> 00:11:31,650 All right, so we're expecting to see Carol, uh, right here. 143 00:11:32,010 --> 00:11:36,470 So we're in for number a floor to fourth apartment. 144 00:11:36,690 --> 00:11:38,600 We just right here. 145 00:11:38,610 --> 00:11:41,220 We mentioned the second key, which is existing one. 146 00:11:41,400 --> 00:11:43,560 And here we did the same. 147 00:11:43,770 --> 00:11:45,930 But this was not an existing one. 148 00:11:45,930 --> 00:11:49,860 So just if it's not there, Python is going to create it for you. 149 00:11:51,170 --> 00:11:59,220 OK, and now we need to remove the fourth apartment of the dictionary. 150 00:12:00,120 --> 00:12:06,270 So what we basically learned is to do the following, right? 151 00:12:06,290 --> 00:12:06,810 We did. 152 00:12:06,810 --> 00:12:07,440 We did. 153 00:12:07,470 --> 00:12:10,230 We learn how to do this and put here value. 154 00:12:10,800 --> 00:12:19,290 But now we want to do it in a nested way because we want to remove a the whoever is in the fourth apartment. 155 00:12:19,720 --> 00:12:21,990 Um, yeah, sorry. 156 00:12:21,990 --> 00:12:24,530 Not the fourth but the first. 157 00:12:24,570 --> 00:12:24,880 Right. 158 00:12:25,320 --> 00:12:28,350 So we want to remove whoever in the first apartment. 159 00:12:28,560 --> 00:12:36,390 But if we will put the value of a floor one here, what are we going to achieve by that is removing 160 00:12:36,390 --> 00:12:43,650 the whole floor and we don't want to remove the whole floor because we just want to remove this thing. 161 00:12:44,430 --> 00:12:51,460 So before we making the pop, let's do what we did in the second assignment. 162 00:12:51,480 --> 00:12:57,230 So right here, we have drilled down once, OK, to get to where we want. 163 00:12:57,510 --> 00:12:59,910 So let's try to do it here as well. 164 00:13:00,390 --> 00:13:02,250 Let's do it like this. 165 00:13:03,750 --> 00:13:08,630 Drill down once and after we're inside floor number one. 166 00:13:08,640 --> 00:13:12,240 OK, so let's bring this inside here, OK? 167 00:13:12,480 --> 00:13:18,900 And inside here, we would like to pop the first apartment. 168 00:13:20,310 --> 00:13:23,140 I because this is what we want to remove. 169 00:13:23,580 --> 00:13:25,210 So we're inside one. 170 00:13:25,260 --> 00:13:26,090 We're inside here. 171 00:13:26,490 --> 00:13:31,980 We're looking at the attendants and then we head straight over to the first apartment and remove it. 172 00:13:32,580 --> 00:13:34,170 And let's bring that. 173 00:13:46,020 --> 00:13:49,920 After removing the first apartment. 174 00:13:51,940 --> 00:13:52,750 All right. 175 00:13:57,590 --> 00:14:04,880 Oh, right, so what are we expecting to see now is this thing, first apartment and Rachel are removed 176 00:14:05,150 --> 00:14:05,810 completely. 177 00:14:08,320 --> 00:14:16,420 OK, so we have seen seeing here only second apartment on the first floor, so this is a success. 178 00:14:17,050 --> 00:14:17,950 Oh, OK. 179 00:14:18,220 --> 00:14:19,530 So that's about it. 180 00:14:19,630 --> 00:14:20,890 Regarding the practice. 181 00:14:21,310 --> 00:14:22,660 This was a bit challenging. 182 00:14:22,660 --> 00:14:23,620 I think you can agree. 183 00:14:24,400 --> 00:14:28,450 It's not like practicing shrinks or integers. 184 00:14:28,450 --> 00:14:29,830 It's a bit more complicated. 185 00:14:30,100 --> 00:14:33,630 It's not a regular list or a regular dictionary. 186 00:14:33,640 --> 00:14:35,050 It is a nested dictionary. 187 00:14:35,050 --> 00:14:36,940 And you have to think a bit deeper here. 188 00:14:37,330 --> 00:14:42,040 And also the fifth assignment was a bit harder than the rest. 189 00:14:42,490 --> 00:14:43,410 But it's OK. 190 00:14:43,570 --> 00:14:45,950 I want you to use your brains hard. 191 00:14:46,120 --> 00:14:47,950 I want you to fight with the code. 192 00:14:48,130 --> 00:14:52,120 I want you to struggle because once you struggle, you become a ninja. 193 00:14:52,120 --> 00:14:56,400 And my job is to prepare you to be a ninja at the end of this course. 194 00:14:56,680 --> 00:15:06,430 So, OK, so don't get upset if you are not able to resolve all the assignments because some students 195 00:15:06,430 --> 00:15:10,000 are writing me the some of the assignments are a bit hard. 196 00:15:10,150 --> 00:15:12,640 They're supposed to be hard, especially the fifth one. 197 00:15:12,850 --> 00:15:17,020 And I what I want to challenge you all the time, so don't worry about it. 198 00:15:17,020 --> 00:15:17,710 It's OK. 199 00:15:17,710 --> 00:15:18,880 That is challenging. 200 00:15:18,880 --> 00:15:23,200 It's OK that sometimes you are not completing all the assignments. 201 00:15:23,410 --> 00:15:28,570 And our job here is to practice to see as much examples as we have. 202 00:15:28,720 --> 00:15:36,820 And also, I really recommend you to take this code and start playing it with it in your spare time. 203 00:15:36,820 --> 00:15:39,250 Regardless of our videos and lectures. 204 00:15:39,910 --> 00:15:44,800 Just make a new class and start creating your own dictionaries. 205 00:15:44,800 --> 00:15:52,090 Try maybe even to do a triple nested dictionary and try to extract values out of there and try to add 206 00:15:52,090 --> 00:15:52,900 sales there. 207 00:15:53,020 --> 00:15:59,410 And this is the only way to learn, practice, practice and practice one more time and also to make 208 00:15:59,410 --> 00:16:06,160 some manipulations and changes and not always going by the book or by the instructor, but doing things 209 00:16:06,160 --> 00:16:07,870 by yourself creatively. 210 00:16:08,740 --> 00:16:10,690 And this is how it goes to your brain. 211 00:16:11,110 --> 00:16:13,930 And I have like a classic metaphor. 212 00:16:13,930 --> 00:16:23,710 For example, as you go to way, if you go to a waterfall, never, never mind in what country or where, 213 00:16:23,890 --> 00:16:31,930 if you go to a waterfall and if you can see if you can find stones under the waterfall, like literally 214 00:16:31,930 --> 00:16:39,310 where the water falls on, you can see the stones are rounded, OK, and that's not the natural way 215 00:16:39,310 --> 00:16:40,840 of stones being right. 216 00:16:40,840 --> 00:16:46,810 Because like usually stones are Shappi and they have corners. 217 00:16:47,020 --> 00:16:50,620 But where you have a waterfall, the stones are rounded. 218 00:16:50,620 --> 00:16:51,700 And how is that? 219 00:16:52,030 --> 00:16:59,440 How is that because water falls on the stones and how it does this effect on the stones. 220 00:16:59,740 --> 00:17:01,060 And I'll tell you how. 221 00:17:01,060 --> 00:17:11,170 And this connects to our course directly because even water, when the dripping tip of the ship, if 222 00:17:11,170 --> 00:17:18,670 they're doing it consistently again and again and again, eventually it can even shape a stone, which 223 00:17:18,670 --> 00:17:20,620 is really, really hard material. 224 00:17:20,830 --> 00:17:23,830 So this is my point to you. 225 00:17:23,830 --> 00:17:24,610 This is my 226 00:17:28,090 --> 00:17:28,860 this is my idea. 227 00:17:28,900 --> 00:17:38,530 And trying to tell you that if you practice continuously, the material will sink in your minds and 228 00:17:38,530 --> 00:17:41,020 eventually you would understand everything perfectly. 229 00:17:41,260 --> 00:17:41,620 All right. 230 00:17:41,710 --> 00:17:42,670 So that's about it. 231 00:17:42,670 --> 00:17:49,990 Guys, we have completed the dictionary part and see you in the next video where we continue data collections. 232 00:17:50,410 --> 00:17:50,950 Bye bye.