WEBVTT 1 00:00:01.180 --> 00:00:05.180 So continuing on with Dictionaries, I mentioned in a previous video 2 00:00:05.180 --> 00:00:07.300 after the challenge, there was a couple of more things to cover. 3 00:00:07.300 --> 00:00:10.700 Before I start that, I just wanted to let you know that I've changed to a different 4 00:00:10.700 --> 00:00:11.480 theme for my videos. 5 00:00:11.480 --> 00:00:13.150 You can see the background. 6 00:00:13.150 --> 00:00:15.130 We're now using darcula, and the reason for 7 00:00:15.130 --> 00:00:17.400 that is you've probably noticed in the last few videos, 8 00:00:17.400 --> 00:00:21.620 whenever a dialogue box Pops up, the buttons look out of place. 9 00:00:21.620 --> 00:00:23.820 Because what I've done is I've increased the font size so 10 00:00:23.820 --> 00:00:25.270 that you can see these videos easier. 11 00:00:25.270 --> 00:00:29.740 But there seems to be a bug, at the moment, in the white background. 12 00:00:29.740 --> 00:00:31.820 A standard thing that comes with IntelliJ. 13 00:00:31.820 --> 00:00:33.850 And if I change to this thing, that problem goes away. 14 00:00:33.850 --> 00:00:35.740 So we'll see how we go with this color. 15 00:00:35.740 --> 00:00:36.730 Hopefully it's still good. 16 00:00:36.730 --> 00:00:39.230 And give me some feedback, if you wouldn't mind, please, and 17 00:00:39.230 --> 00:00:41.970 let me know if you're still being able to see this video. 18 00:00:41.970 --> 00:00:46.140 And still not very clear on your screen but certainly good to work with. 19 00:00:46.140 --> 00:00:50.600 I think I mentioned earlier in the course when we're installing intellij that I 20 00:00:50.600 --> 00:00:53.280 actually prefer this for my everyday development. 21 00:00:53.280 --> 00:00:57.750 Okay moving on we're going to look at two more dictionary methods that can be really 22 00:00:57.750 --> 00:01:01.240 useful in your everyday path in programming First one is the update method 23 00:01:01.240 --> 00:01:04.140 and that allows you to combine two dictionaries together. 24 00:01:04.140 --> 00:01:05.530 So that's really useful. 25 00:01:05.530 --> 00:01:08.120 And the second one is the copy method which is used to 26 00:01:08.120 --> 00:01:10.220 create a copy of a dictionary. 27 00:01:10.220 --> 00:01:12.950 And I've created a new file I've called fruit.pie and 28 00:01:12.950 --> 00:01:15.550 I've just pasted in our fruit. 29 00:01:15.550 --> 00:01:19.370 from the original dictionary videos that we did bout that. 30 00:01:19.370 --> 00:01:20.990 So I've posted those back in again. 31 00:01:20.990 --> 00:01:21.620 And we're gonna do, 32 00:01:21.620 --> 00:01:24.330 what we're gonna do now is we're gonna store some veggies as well. 33 00:01:24.330 --> 00:01:25.980 So we're gonna put print fruit. 34 00:01:28.390 --> 00:01:32.780 Then we're gonna do veg for veggies equals, let's add some vegetables. 35 00:01:33.900 --> 00:01:35.290 Cabbage, everyone's favorite. 36 00:01:36.940 --> 00:01:42.775 Especially children, every child is maybe not every 37 00:01:42.775 --> 00:01:47.531 childs favorite 38 00:01:47.531 --> 00:01:51.943 sprouts, lovely. 39 00:01:53.150 --> 00:01:54.960 That's debatable I think. 40 00:01:54.960 --> 00:01:57.300 And spinach, which is something I actually do like. 41 00:01:59.120 --> 00:02:03.140 Can I have some more fruit please, 42 00:02:03.140 --> 00:02:05.660 which would be a typical response from people to spinach. 43 00:02:05.660 --> 00:02:09.280 Okay, so we've added three entries in our dictionary and 44 00:02:09.280 --> 00:02:11.200 we're just going to print that out as well. 45 00:02:11.200 --> 00:02:13.420 We can run that. 46 00:02:13.420 --> 00:02:17.080 So at the moment Oops, I need to cancel out of that, so disconnect. 47 00:02:17.080 --> 00:02:19.790 That does come up and you're wondering what's going on, it's because challenge is 48 00:02:19.790 --> 00:02:24.835 selected, which was the last path and file that was run in this project, so I can 49 00:02:24.835 --> 00:02:29.470 right-click the current source file run fruit, and that will then work and then 50 00:02:29.470 --> 00:02:33.750 subsequently I can come in here and select fruit or just make sure that's selected. 51 00:02:33.750 --> 00:02:36.970 But okay, in this example you can see that we've successfully 52 00:02:36.970 --> 00:02:39.810 created two dictionaries and they're separate as you can see. 53 00:02:39.810 --> 00:02:42.550 One's got fruit and other has got vegetables. 54 00:02:42.550 --> 00:02:43.560 So that's working fine. 55 00:02:43.560 --> 00:02:46.290 But we can actually combine those together. 56 00:02:46.290 --> 00:02:50.000 Using the update method, and when we do that we pass the other one as a parameter. 57 00:02:50.000 --> 00:02:54.000 So we can do something like this veg.update(fruit) and 58 00:02:55.130 --> 00:02:59.060 that's adding the fruit dictionary to the veg dictionary. 59 00:02:59.060 --> 00:03:06.520 So we then print that out and run that You can see now on that third line of output, 60 00:03:06.520 --> 00:03:12.062 you've got all the entries, and you can see there we've also got sprouts there. 61 00:03:12.062 --> 00:03:14.730 Cabbage there, etcetera. 62 00:03:14.730 --> 00:03:15.870 So we've got both of them combined. 63 00:03:15.870 --> 00:03:19.070 So that's a really handy command if you've got two dictionaries and 64 00:03:19.070 --> 00:03:20.840 you just want to combine them together. 65 00:03:20.840 --> 00:03:23.280 There of course is nothing stopping us from also doing this. 66 00:03:23.280 --> 00:03:27.240 We could have done fruit.update And 67 00:03:27.240 --> 00:03:31.760 that is added to the fruit dictionary so I obviously left this example line 13 add 68 00:03:31.760 --> 00:03:36.700 the veg dictionary to fruit, I am going to take that again and the entry on line 15, 69 00:03:36.700 --> 00:03:40.670 of course that is adding the fruit dictionary To veg. 70 00:03:40.670 --> 00:03:42.270 Now, the method returns none. 71 00:03:42.270 --> 00:03:45.700 And if you remember from our discussions of the list sort method, 72 00:03:45.700 --> 00:03:50.620 a new list isn't returned when you call sort, and with dictionary update method, 73 00:03:50.620 --> 00:03:52.540 a new dictionary is not returned either. 74 00:03:52.540 --> 00:03:55.810 So, the reason that we've talked about this and mentioned this a few times 75 00:03:55.810 --> 00:03:59.520 is primarily for people who are used to other programming languages and 76 00:03:59.520 --> 00:04:01.250 may expect a new object to be returned. 77 00:04:01.250 --> 00:04:03.839 But just to confirm that, if I do something like this, 78 00:04:05.250 --> 00:04:09.960 Print is what I'll do, I'll do at the end here, and then here. 79 00:04:11.540 --> 00:04:17.011 I can do, print (fruit.update (veg)), 80 00:04:17.011 --> 00:04:21.780 then I can do print(fruit). 81 00:04:21.780 --> 00:04:26.500 So we actually run that You see the first line we got none. 82 00:04:26.500 --> 00:04:30.370 And the second line you can see we've clearly got fruit and 83 00:04:30.370 --> 00:04:32.190 some vegetables in there. 84 00:04:32.190 --> 00:04:34.330 So, very important to remember it doesn't return anything. 85 00:04:34.330 --> 00:04:38.810 You know if you wanted to create a new dictionary that contained all the items 86 00:04:38.810 --> 00:04:42.820 say from fruit and veg, but you didn't wanna modify the original dictionaries. 87 00:04:42.820 --> 00:04:47.060 Then instead of using update it's a better option to use the copy method instead. 88 00:04:47.060 --> 00:04:50.490 So we could do something like this, we could put, 89 00:04:50.490 --> 00:04:54.420 nice and nasty equals fruit dot copy. 90 00:04:54.420 --> 00:04:58.533 And we could do nice and nasty dot update. 91 00:04:58.533 --> 00:05:03.449 (veg) print (nice and 92 00:05:03.449 --> 00:05:09.270 nasty) and just comment some of these lines out, so 93 00:05:10.720 --> 00:05:16.038 if you run that now, you can see that clearly there we've done the .copy and 94 00:05:16.038 --> 00:05:20.050 then the.update and so that last line you can see were really got 'sprouts' in there 95 00:05:20.050 --> 00:05:22.210 And fruit, so we've got fruit and vegetables, so 96 00:05:22.210 --> 00:05:26.770 let's combine them again, creating a new dictionary called nice and nasty. 97 00:05:26.770 --> 00:05:30.660 And fruit and veg, both of those dictionaries weren't modified at all, and 98 00:05:30.660 --> 00:05:32.570 so, as confirmation, nice and 99 00:05:32.570 --> 00:05:36.560 nasty, that dictionary now contains all the items from both. 100 00:05:36.560 --> 00:05:41.430 And just to confirm that, you can do print veg dot fruit. 101 00:05:42.780 --> 00:05:43.280 And run that. 102 00:05:44.360 --> 00:05:45.260 And that should confirm. 103 00:05:45.260 --> 00:05:48.440 You have vegetables on the second to last line there. 104 00:05:48.440 --> 00:05:49.400 And it's only vegetables and 105 00:05:49.400 --> 00:05:54.500 then the last line you can see scrolling over, that's all fruit. 106 00:05:54.500 --> 00:05:56.940 There's no vegetables. 107 00:05:56.940 --> 00:05:58.870 So that's a good way if you wanna copy. 108 00:05:58.870 --> 00:06:01.040 One example, one that's gonna be extremely useful. 109 00:06:01.040 --> 00:06:04.610 What we're gonna do is make some improvements to the user interface of our 110 00:06:04.610 --> 00:06:05.790 adventure game. 111 00:06:05.790 --> 00:06:09.300 So I'm gonna go back to the challenge, and I'm going to copy all of this. 112 00:06:11.840 --> 00:06:15.490 We're just gonna create a new folder just to preserve that source code if you need 113 00:06:15.490 --> 00:06:19.510 to go back to New > Python, we'll just call this one game. 114 00:06:21.460 --> 00:06:22.690 I'm gonna paste that code in again, 115 00:06:22.690 --> 00:06:26.440 that was the last code from the challenge That we did in the last video. 116 00:06:26.440 --> 00:06:29.280 So I think that's something that would be extremely useful. 117 00:06:29.280 --> 00:06:32.260 We've gotta change the user interface of this adventure game. 118 00:06:32.260 --> 00:06:35.730 And wouldn't it be useful if players could enter the name of the location 119 00:06:35.730 --> 00:06:37.330 rather than a direction? 120 00:06:37.330 --> 00:06:41.050 So I'm still allowing them to go there if there's an exit from the current location. 121 00:06:41.050 --> 00:06:43.950 In other words, an account temper of the map, but for example, 122 00:06:43.950 --> 00:06:47.080 it would allow them to type hill from the road instead of west to get to the hill. 123 00:06:47.080 --> 00:06:50.850 So the easiest way to implement the change with the current count we've got 124 00:06:50.850 --> 00:06:55.000 is to extend the vocabulary dictionary to include the location names. 125 00:06:55.000 --> 00:06:56.940 So what we're gonna do is extend that. 126 00:06:56.940 --> 00:06:59.380 So we're still gonna leave in our other directions. 127 00:06:59.380 --> 00:07:04.690 But if we then go back in there and put in So road 1 128 00:07:08.338 --> 00:07:13.428 and what's this going to be called now? 129 00:07:17.430 --> 00:07:21.430 Hill 2 building 130 00:07:23.237 --> 00:07:28.214 3 valley It's gonna be four and 131 00:07:28.214 --> 00:07:31.899 forest. 132 00:07:31.899 --> 00:07:34.360 Five. 133 00:07:34.360 --> 00:07:37.050 But the thing is we can't use a direction as the value. 134 00:07:37.050 --> 00:07:40.160 Although Talking road from the forest moved south 135 00:07:40.160 --> 00:07:42.940 talking road from the building moved west, and 136 00:07:42.940 --> 00:07:47.190 from the valley north so one solution that keeps maintenance of the exits dictionary 137 00:07:47.190 --> 00:07:51.520 simple is to use the location number of street, then For the valley. 138 00:07:51.520 --> 00:07:53.930 Then we have destination of one of the exits dictionary. 139 00:07:53.930 --> 00:07:56.400 We just had another entry one, one so 140 00:07:56.400 --> 00:07:59.130 we can maintain the exits without checking the map each time. 141 00:07:59.130 --> 00:08:03.090 And again, that's easy to see and to not actually describe. 142 00:08:03.090 --> 00:08:04.580 So let's go ahead and update that now. 143 00:08:04.580 --> 00:08:06.200 So what we need to do. 144 00:08:06.200 --> 00:08:08.450 It's for each location we need to put in the corresponding number. 145 00:08:08.450 --> 00:08:11.050 So for number 2 here we've got west 2. 146 00:08:11.050 --> 00:08:17.775 What we then need to do is put 2:2. 147 00:08:17.775 --> 00:08:23.611 East will be 3:3, 148 00:08:23.611 --> 00:08:30.870 North is going to be 5: five and south. 149 00:08:30.870 --> 00:08:35.810 You guessed it 4:4 then we don't need to do anything with qui, 150 00:08:35.810 --> 00:08:37.980 so we'll leave that as it is. 151 00:08:37.980 --> 00:08:41.900 So likewise for location two, we need to also put in a five here. 152 00:08:41.900 --> 00:08:45.600 So five is the key and five is the location. 153 00:08:46.800 --> 00:08:54.370 The third one, for west we're going to put 1, 1 for the location. 154 00:08:54.370 --> 00:09:00.140 And for location 4 we're gonna do the same, we're gonna put 1, column 1. 155 00:09:00.140 --> 00:09:05.330 And the second one after west we're gonna put 2 column 2, 156 00:09:05.330 --> 00:09:07.730 we're gonna leave quid in there. 157 00:09:07.730 --> 00:09:12.460 And on the last line, we need to put "2": 2. 158 00:09:12.460 --> 00:09:16.200 "2" being the key, 2 being the location. 159 00:09:16.200 --> 00:09:19.968 And cuz we're going south, we also need to add a "1": 1, as well. 160 00:09:19.968 --> 00:09:23.650 So essentially, the corresponding direction, we've 161 00:09:23.650 --> 00:09:28.770 also added that number into it as well, so that it matches up WIth our vocabulary. 162 00:09:28.770 --> 00:09:31.530 So, if you go ahead now and run this, and I'm gonna change this, 163 00:09:31.530 --> 00:09:35.300 we need to right-click first, actually, and click run game. 164 00:09:35.300 --> 00:09:38.970 I think we still should be able to type in so south, north, 165 00:09:38.970 --> 00:09:41.900 so we should always be able to type in valley. 166 00:09:41.900 --> 00:09:44.810 That takes us to a valley. 167 00:09:44.810 --> 00:09:48.930 And road, to take us back to where we were before, 168 00:09:48.930 --> 00:09:53.900 and we can still get--could still So that's pretty neat. 169 00:09:53.900 --> 00:09:55.770 So providing there's an exit tour, 170 00:09:55.770 --> 00:10:00.570 we're able to type in the destination name to get there from our current location. 171 00:10:00.570 --> 00:10:02.740 Now there is actually an issue with this though. 172 00:10:02.740 --> 00:10:05.870 So the list of available exits from a location, 173 00:10:05.870 --> 00:10:10.250 As you know is built up from the keys of the exits dictionary for that location. 174 00:10:10.250 --> 00:10:14.100 So now that we've added the extra entries to the dictionary, 175 00:10:14.100 --> 00:10:16.490 we end up with a load of numbers in the value of x's list. 176 00:10:16.490 --> 00:10:19.630 And just to run that again, 4352, etc. 177 00:10:19.630 --> 00:10:23.010 You can see these extra numbers that are being added there. 178 00:10:23.010 --> 00:10:24.950 Now we do have a problem with this, though. 179 00:10:24.950 --> 00:10:27.810 The list of available x's from a location 180 00:10:27.810 --> 00:10:32.140 As you can see it's built up from the keys of the exits dictionary. 181 00:10:32.140 --> 00:10:37.600 So we're using this to go through, we're cycling through the line 42, the keys 182 00:10:37.600 --> 00:10:43.670 dictionary or the exits dictionary and building up a list of available exits. 183 00:10:43.670 --> 00:10:45.120 So consequently of course when we run it, 184 00:10:45.120 --> 00:10:50.930 which you saw when I run it previously We've got now all these numbers and 185 00:10:50.930 --> 00:10:54.020 they're 4, 3, 2, 5 as well as valid directions. 186 00:10:54.020 --> 00:10:56.130 Now that's actually a problem, it doesn't look good. 187 00:10:56.130 --> 00:11:01.260 So what we really need to do is store the nine destinations in a separate dictionary 188 00:11:01.260 --> 00:11:03.820 then combine then at the point when we check the players input. 189 00:11:03.820 --> 00:11:06.690 And what we actually wanna do here, I'll just connect that. 190 00:11:06.690 --> 00:11:09.280 Cuz you really wanna undo those changes that we've made and 191 00:11:09.280 --> 00:11:10.850 create a combined directory. 192 00:11:10.850 --> 00:11:12.260 So am gonna undo this. 193 00:11:12.260 --> 00:11:16.100 The easiest way for me to fix this, is to go back and just copy and 194 00:11:16.100 --> 00:11:17.160 paste from our old challenge. 195 00:11:17.160 --> 00:11:22.070 So am gonna copy the old exits And I'll paste that in. 196 00:11:22.070 --> 00:11:23.810 Go back to our game. 197 00:11:23.810 --> 00:11:25.540 Pi file, paste that in. 198 00:11:25.540 --> 00:11:27.540 So we're left now with our original exits. 199 00:11:27.540 --> 00:11:30.140 So what we want to do is add a new dictionary called name dex, 200 00:11:30.140 --> 00:11:33.570 that contains those numbers that we've just removed. 201 00:11:33.570 --> 00:11:37.400 So, name x's equals 1. 202 00:11:37.400 --> 00:11:41.340 2 colon 2. 203 00:11:41.340 --> 00:11:45.264 3 colon three. 204 00:11:45.264 --> 00:11:49.220 Five: five and 205 00:11:49.220 --> 00:11:53.180 four colon four. 206 00:11:53.180 --> 00:11:56.280 So that's our first dictionary for the location one. 207 00:11:56.280 --> 00:12:01.000 Location two, we only had the one, and that was to location five. 208 00:12:04.020 --> 00:12:08.274 Location three, we only had one again. 209 00:12:10.770 --> 00:12:13.920 1, 4, we had a couple. 210 00:12:15.660 --> 00:12:18.550 We 1, 1 and also 2, 2. 211 00:12:18.550 --> 00:12:24.824 And lastly, location five Also had 2 so 212 00:12:24.824 --> 00:12:32.440 2:2 1:1 like so, so that's our NamedExits, 213 00:12:32.440 --> 00:12:37.250 so what we wanna do then is create a combined directory Copy of the location's 214 00:12:37.250 --> 00:12:42.040 exit dictionary and updating it to include the appropriate named exits. 215 00:12:42.040 --> 00:12:45.330 But there's no point doing all that work if the player's charging to quit. 216 00:12:45.330 --> 00:12:47.790 So what we're going to do is add an else clause to the check for 217 00:12:47.790 --> 00:12:51.160 location zero and prepare our combined dictionary there. 218 00:12:51.160 --> 00:12:53.880 So down here if loc equals zero, break. 219 00:12:53.880 --> 00:12:55.930 And I'm going to add an else. 220 00:12:55.930 --> 00:12:59.363 If it's not location zero, which means we're still moving to another room. 221 00:12:59.363 --> 00:13:06.546 And we're gonna type allExits=exits(loc).copy, 222 00:13:06.546 --> 00:13:09.809 so I'm grabbing a copy of that dictionary and 223 00:13:09.809 --> 00:13:18.970 allExits.update(namedExits[loc]), so 224 00:13:18.970 --> 00:13:21.410 we're grabbing a copy of all the exits 225 00:13:21.410 --> 00:13:24.610 That count in the exits directory from here. 226 00:13:24.610 --> 00:13:28.690 And then what we're doing, and that's for that particular location, and then so 227 00:13:28.690 --> 00:13:30.380 we've created a copy of that. 228 00:13:30.380 --> 00:13:30.880 It's on line 55. 229 00:13:30.880 --> 00:13:33.980 And then line 56 what we're doing is we're updating it. 230 00:13:33.980 --> 00:13:38.130 So we're grabbing a copy of the appropriate entries from the name 231 00:13:38.130 --> 00:13:42.760 dictionary for that location, and adding to the new dictionary, which is all x's, 232 00:13:42.760 --> 00:13:43.970 which we've created. 233 00:13:43.970 --> 00:13:49.690 So consequently, now, instead of here on line 68, checking for the x's location, 234 00:13:49.690 --> 00:13:55.070 at the x's current location, we can change that and test for all x's. 235 00:13:56.170 --> 00:13:58.670 So we're just checking to see whether our direction's in allExits. 236 00:13:58.670 --> 00:14:03.490 And of course, allExits contains both the directions, north, south, east, 237 00:14:03.490 --> 00:14:07.940 west, but also the other locations, the actual numbers, as well. 238 00:14:07.940 --> 00:14:14.160 And of course allExits again, we confirmed now is the west, north, east, west, etc. 239 00:14:14.160 --> 00:14:18.150 But also the named exits as in the numbers as well, 240 00:14:18.150 --> 00:14:21.360 allowing us to use that vocabulary for that purpose. 241 00:14:21.360 --> 00:14:24.190 And the other thing to note is of course we don't need to change anything here. 242 00:14:24.190 --> 00:14:28.780 So line 48, the available exits is now going to correctly look at just 243 00:14:28.780 --> 00:14:32.770 the location, the exits for that particular location, and it's not going to 244 00:14:32.770 --> 00:14:35.910 include any of those numbers that we saw when we previously ran it. 245 00:14:35.910 --> 00:14:40.250 So now if we run this, You'll notice now that the numbers have gone. 246 00:14:40.250 --> 00:14:43.440 We should be able to just use our normal items. 247 00:14:43.440 --> 00:14:45.330 So what I'll do is we'll quit out of that again and we'll run it again. 248 00:14:45.330 --> 00:14:47.390 Just to the same as what we've been doing before. 249 00:14:47.390 --> 00:14:53.150 So south, north, road, should be at the top road. 250 00:14:53.150 --> 00:14:56.850 Nothing will happen cuz we're already there, but we can type, valley. 251 00:14:57.852 --> 00:15:00.240 And we got an error there. 252 00:15:00.240 --> 00:15:02.550 So it's probably a good time to actually debug this. 253 00:15:02.550 --> 00:15:04.530 That's line 69 that's failing. 254 00:15:04.530 --> 00:15:09.990 And I suspect what I've done is I've coded something incorrectly, one of the keys. 255 00:15:09.990 --> 00:15:13.230 And what I failed to do, if we look at it, actually line 69, 256 00:15:13.230 --> 00:15:15.960 probably should have looked at the error straightaway. 257 00:15:15.960 --> 00:15:18.370 If you look at that carefully, lines 68 and 69, 258 00:15:18.370 --> 00:15:21.290 you can probably see what I've done. 259 00:15:21.290 --> 00:15:24.320 So we're looking in our dictionary all exits 260 00:15:24.320 --> 00:15:27.350 then trying to retrieve a location from the exits. 261 00:15:27.350 --> 00:15:31.570 So consequently, the code's gonna work fine if we use west, north, 262 00:15:31.570 --> 00:15:34.630 east, south etc using those sorta locations. 263 00:15:34.630 --> 00:15:36.820 But soon as we start typing in the number it's gonna exit, 264 00:15:36.820 --> 00:15:39.140 it's going to crash rather Because it doesn't exist. 265 00:15:39.140 --> 00:15:43.400 So what I should have done there was make that all exits. 266 00:15:43.400 --> 00:15:47.710 And that should fix it, so we should be able to run that again now, and 267 00:15:47.710 --> 00:15:52.590 still we have to go south, north, but now we should be able to go valley, 268 00:15:52.590 --> 00:15:55.760 and go back to road. 269 00:15:57.270 --> 00:15:59.790 And if we just type road again we should get an error because we can't go in 270 00:15:59.790 --> 00:16:00.580 that direction. 271 00:16:00.580 --> 00:16:04.290 So as you can see, update and copy, really two very useful commands. 272 00:16:04.290 --> 00:16:07.720 So we've covered quite a lot of important concepts in the discussion overall, 273 00:16:07.720 --> 00:16:08.840 of dictionaries. 274 00:16:08.840 --> 00:16:12.490 And it's gone over, now, quite a few videos, including the way that we've 275 00:16:12.490 --> 00:16:16.010 related different data structures by using the location, 276 00:16:16.010 --> 00:16:20.750 the loc variable to access entries in both the locations and exits structures. 277 00:16:20.750 --> 00:16:25.390 And this is only one was to represent allocations and keep that in mind. 278 00:16:25.390 --> 00:16:28.150 So our net could be modeled in very different ways so keep that in mind and 279 00:16:28.150 --> 00:16:30.960 we could have used lists instead of dictionaries for example. 280 00:16:30.960 --> 00:16:35.350 Now dictionaries have the advantage that insertion and deletion are extremely fast. 281 00:16:35.350 --> 00:16:36.900 And that's of little relevance here, 282 00:16:36.900 --> 00:16:41.030 because we're not using those operations but access by key is also extremely fast, 283 00:16:41.030 --> 00:16:43.060 which will be very useful for a game like this. 284 00:16:43.060 --> 00:16:44.790 So I'm gonna finish the video here now. 285 00:16:44.790 --> 00:16:47.510 In the next video we're going to go through another challenge. 286 00:16:47.510 --> 00:16:51.170 We're going to challenge around a standing of dictionaries. 287 00:16:51.170 --> 00:16:52.190 So see you in the next video.