Hi, everybody, welcome.
So this video will console resolving the assignments of dictionaries, the advanced part.
So let's begin more.
Once our project is open, let's click right click on the project.
Then you bite on and give a meaningful name, which will be collections dictionary project.
This advanced, right?
So this would be also, Karl.
Lection dictionary practice.
Advanced.
And here I'm missing Kenny.
All right, it's collections.
Yeah.
All right, so first of all, first assignment was to create a dictionary.
Daksha.
Wary of building attendance, right?
So how do we do it?
All right.
We just do the following thing, we do curly brackets, and then here we would put, by the way, just
a quick note and didn't remember if I already mentioned it.
But it doesn't matter if you put a single quotation mark or a double quotation mark as long as you don't
have one of each.
OK, as long as they're from the same type.
So is the same thing for Python.
So first of all, let's create the floor first floor.
So floor one.
And right after we submitted the key, now we need to submit the right part, which in Nonis the cells,
not Nestel dictionaries would be disvalue about.
In our case, we have a nested cell here with additional key, which will be first apartment like this.
Yeah, and here we have Rachel and then we have second apartment and how we here we have the closet.
Here we have Gene.
By the way, have a look right here.
I know I've said it a single quotation mark here, I have double quotation marks.
Everything's fine, there's no error.
But just for the sake of order, which is going to put single in every one because I like order.
Don't like mixed stuff here.
OK, so we're fine and right after this, and I'm just going to put the comma here, because we have
finished like looking in an overview.
So this is the parent cell.
We have the key section here and we have the sort of value here.
And once we finished it, we put a comma.
And because I'm close to the end of the line here, I can also go down the line using enter.
And right here, it's more static, you know, and right here I'm going to pull floor to.
Yeah.
And the same thing.
So here we have quelque curly brackets and we have here the third.
Apartment.
With Jack, which is Joe is the resident, so you see, like if looking at the dictionary now, it looks
pretty complicated, right?
How the curly brackets and then you have a key and again, curly brackets and ECOMIL, what's going
on here?
But if you drill down and break break it down into small pieces, if you break down the problem into
small pieces, so it's pretty easy.
So you have a key here.
Correct.
Then you have two dots and then you have the place of the value.
But instead of the value, you just create another dictionary, just open the brackets and put another
key of the value, comma, key value.
Close it.
OK, it's the same thing, always the same thing all over again.
All right.
Also here we have a key to that curly brackets, key and value, and then the closing brackets of the
whole dictionary.
All right, so let's print out the dictionary.
Yeah, so casting and then building attendance, yeah, and let's run it there we have it.
So we have the dictionary printed out.
Let's head over to the second assignment now.
We are we were asked to extract the defendants names name who lives on the first floor, second apartment.
Right.
So we want to extract the value of who lives, whoever lives in the first floor, in the second apartment.
So first floor, second apartment is this girl.
So now what we need to do.
Oh, I'm sorry.
I have a mistake.
Right.
We were asked to extract nested cell items.
Sorry, extract.
Nested sale items like this.
So what we have now to do, what we need to do now is to, uh, mention the dictionary and as we did
already, just to mention the key here.
And then once we mention the key, all right, we could we would print out all of these items.
OK, let's cover it with print, uh, first.
First floor items of the dictionary.
And string casting like this and the right click in the wrong, let's see if we were right.
All right.
So now we have printed out all the items which are in the first floor and these are the items here.
So what's the logic behind it?
You just mentioned the key and then it will give you the what what appears on the right side of the
two dots.
So basically, this is what we need.
And now we have by the way, I want just want to mark here the number of the assignments.
So it would be more clear in the print out what we're dealing with.
And now we were asked to extract of whoever lives.
And the second apartment, right?
Which is gin and what we basically need to do, so let's have a look at this.
All right.
So let's learn from our examples right here.
We drilled down one level.
What do you mean one level?
We just entered the dictionary.
We entered it, and then we drilled down only one level.
We just took the key and we said, hey, give me all what you have for this key.
All right?
But now we need to drill down twice.
We need to take this key and afterwards to take also this key.
OK, so we already seen an example for it in the previous video and sorry, not the previous one before
it.
And basically what we need to do is, again, to mention floor one here like this and right after to
drill down one more.
And what you need to do is to get the second apartment key like this.
And cover it with print, obviously.
Brent of the then then and the second apartment like this.
And this is assignment number three.
All right, so we have some malfunction here, we missed the plus side, of course.
Let's run it.
What we expecting to see is Ginne, obviously.
OK, there you ha.
There we have it.
We see Jeanne.
So we drill down once here with this key and then we drilled down twice with this key.
And then we get the gin, then we get the resident.
All right.
So the assignment number four was to add a fourth apartment to the dictionary in floor two.
All right.
So add a fourth apartment on floor two.
And how do we do it?
Basically, we want to put Carol there.
So we mention the dictionary and then we mention the first key that we want to access, which is for
two.
And then we mentioned the second key, which is not existing at the moment, which is apartment four.
And then we put the equals and we put Carol inside the place that we want.
We want to put her in the key number, first key, which will be four two.
And then we want another key or floor number for.
All right.
Like, we have third apartment.
We want to put it here, inside here.
So maybe it's better to put it like fourth apartment because it's all letters here.
No numbers.
All right.
So this is the second drill down.
Let's run it.
Oh, I did it printed, of course.
All right, so we're expecting to see Carol, uh, right here.
So we're in for number a floor to fourth apartment.
We just right here.
We mentioned the second key, which is existing one.
And here we did the same.
But this was not an existing one.
So just if it's not there, Python is going to create it for you.
OK, and now we need to remove the fourth apartment of the dictionary.
So what we basically learned is to do the following, right?
We did.
We learn how to do this and put here value.
But now we want to do it in a nested way because we want to remove a the whoever is in the fourth apartment.
Um, yeah, sorry.
Not the fourth but the first.
Right.
So we want to remove whoever in the first apartment.
But if we will put the value of a floor one here, what are we going to achieve by that is removing
the whole floor and we don't want to remove the whole floor because we just want to remove this thing.
So before we making the pop, let's do what we did in the second assignment.
So right here, we have drilled down once, OK, to get to where we want.
So let's try to do it here as well.
Let's do it like this.
Drill down once and after we're inside floor number one.
OK, so let's bring this inside here, OK?
And inside here, we would like to pop the first apartment.
I because this is what we want to remove.
So we're inside one.
We're inside here.
We're looking at the attendants and then we head straight over to the first apartment and remove it.
And let's bring that.
After removing the first apartment.
All right.
Oh, right, so what are we expecting to see now is this thing, first apartment and Rachel are removed
completely.
OK, so we have seen seeing here only second apartment on the first floor, so this is a success.
Oh, OK.
So that's about it.
Regarding the practice.
This was a bit challenging.
I think you can agree.
It's not like practicing shrinks or integers.
It's a bit more complicated.
It's not a regular list or a regular dictionary.
It is a nested dictionary.
And you have to think a bit deeper here.
And also the fifth assignment was a bit harder than the rest.
But it's OK.
I want you to use your brains hard.
I want you to fight with the code.
I want you to struggle because once you struggle, you become a ninja.
And my job is to prepare you to be a ninja at the end of this course.
So, OK, so don't get upset if you are not able to resolve all the assignments because some students
are writing me the some of the assignments are a bit hard.
They're supposed to be hard, especially the fifth one.
And I what I want to challenge you all the time, so don't worry about it.
It's OK.
That is challenging.
It's OK that sometimes you are not completing all the assignments.
And our job here is to practice to see as much examples as we have.
And also, I really recommend you to take this code and start playing it with it in your spare time.
Regardless of our videos and lectures.
Just make a new class and start creating your own dictionaries.
Try maybe even to do a triple nested dictionary and try to extract values out of there and try to add
sales there.
And this is the only way to learn, practice, practice and practice one more time and also to make
some manipulations and changes and not always going by the book or by the instructor, but doing things
by yourself creatively.
And this is how it goes to your brain.
And I have like a classic metaphor.
For example, as you go to way, if you go to a waterfall, never, never mind in what country or where,
if you go to a waterfall and if you can see if you can find stones under the waterfall, like literally
where the water falls on, you can see the stones are rounded, OK, and that's not the natural way
of stones being right.
Because like usually stones are Shappi and they have corners.
But where you have a waterfall, the stones are rounded.
And how is that?
How is that because water falls on the stones and how it does this effect on the stones.
And I'll tell you how.
And this connects to our course directly because even water, when the dripping tip of the ship, if
they're doing it consistently again and again and again, eventually it can even shape a stone, which
is really, really hard material.
So this is my point to you.
This is my
this is my idea.
And trying to tell you that if you practice continuously, the material will sink in your minds and
eventually you would understand everything perfectly.
All right.
So that's about it.
Guys, we have completed the dictionary part and see you in the next video where we continue data collections.
Bye bye.