Hi, everybody, and welcome.
Today, we will discuss Stapel and this lecture would cover the advanced part, theoretical part regarding
Topal Thapar is our fourth and last collection.
Let's start over with a quick example, a reminder of how Topal is structured.
It has has round brackets with items inside quotation marks divided with a comma.
Those of you who study hard and follow the lectures would find the first manipulation title very, very
weird.
Change their value.
And why?
Because if you recall, once we discussed Topal basics and two lectures back, I've mentioned Topo's
characteristics.
And the three main characteristics were that topple existing cells that cannot be updated or changed.
New cells cannot be added and existing cells cannot be deleted or so tuple is a basically standstill
collection that does not like changes.
So why do we see a change cell value Tyto here?
Is it even possible?
So the reason that you see it is very, very simple.
This course goal is to bring you to a game into make you into a ninja developers.
I am not looking for mediocre developers finishing these course.
I'm willing to make you and ninja developers and we are not just going to cover the basic part that
you can find online.
You will find you very challenging topics that I will walk you through together.
All right.
So like naturally tuple Topal, sales cannot be changed.
But Python stands for its name because Python is flexible.
And this is exactly what I'm going to show you this video.
So there is a trick that can make you that can give you the ability to change tuple cell values.
Now, we show it to you in the following minutes.
All right.
So we learned in previous lectures that Toppo cells are unchangeable, but still there's a way to overcome
this by declaring.
So, first of all, before it here in the orange box, you can see our declared the fruit tuple.
It has banana, it has berry and mango.
And they're very, very important thing that it's actually not a tuple.
I created the list here.
Let me just change it.
Yep.
Like this.
Now it's good.
Yeah, so I've created here a simple Toppo, and now let's see what we can do.
So first of all, the clearway list collection, just a regular declaration is always you can see it
here in the purple box.
I've created a declaration called Fruit List.
Then after the equals mark, I casted the existing tuple into into a list is the same as casting a string
into an end and int into a string.
Same as we do in print all the time as we doing like as we're doing like this.
Yeah, we're putting a casting into a string.
So this, this is also casting what we see right here in the purple line.
We are casting a tuple into a list.
OK, it's very easy.
So now we have all the items of Toppo inside this first list.
And once we have a list, changing values, adding sales is very, very easy.
And you can see it right here in the third line in the Green Line Ed item into the list.
This we already know how to do.
So I'm just adding cell number in index number one.
I'm adding a Strawbery.
All right.
And then after I added it, I'm casting the list back to topple here in the light light.
Blue collar cast back double, so you see here, the Topal keyword bolded, and inside it you see the
list.
So this casts back to topple and fruit stubble has now the strawberry item inside it.
It's cool, right?
So by nature, you cannot change the apple cells.
But if you cast it into a list, then you can add your your cells and then cast it back to double.
This is exactly what developers are expected to do to think outside the box.
All right.
From here, let's head off to the last next and last manipulation that we learned here in advance.
Double lecture.
If you want to create a single cell tuple and we naturally going to do it like this, just declare it.
And inside the brackets, inside quotation marks, put our value.
This will give us a wrong.
This will give us a wrong result.
And why?
Because if later on we want to type one to print the type of the variable that we just declared, you'll
remember this one, by the way.
I've mentioned it in the previous lecture and in previously lectures as well.
So once we print the type of something we can get the output, which will be the type of the variable
or the collection.
So in our case, once we print this out, we'll get an output of string.
So this is not what we want.
We want to create a tuple with a single cell.
So how can we actually achieve that?
We can achieve it by using this manipulation.
We just declared tuple and inside after we we put a single cell here, we just also leave a comma and
then we close the brackets.
Then once we try to print out the type of the output will be tuple.
So this part is irrelevant.
Yep.
And this is easy, but it's important to know.
And once you leave, you leave a comma here, the type of it will become Toppo.
All right.
So this concludes the theoretical part of each advanced Stupples.
In the next video, you will see some challenging assignments regarding tuple, and this would conclude
our collection part in our course.
And then we will go straight ahead for more interesting topics.
Topic part was a bit long topic, but very, very important.
So don't underestimate it and practice it in the next video.
Thank you.
Bye bye.