Hell, everyone, so in this particular session, we would learn about string slicing and indexing,
so would see how we can retrieve a particular word or a subset of a word using indexing.
So let's I want to get the intent of the word.
I can get that by using land function and applying it on X. So we can see that the length of X is 17
characters.
If I want to retrieve the first character, it would be retrieved by X zero, which is the first index,
the zeroth index, so zero, the Nexus X..
So if I go to one, it is any.
If you go to three, this is L and if you go to 17.
It is because the length of the wood goes from zero to next to 16 Pantex and the length is 17 characters,
so it will go only to 16.
Now, if I want to see the entire world, I can simply see it using X.
Now, if I want to retrieve, let's say, a word from third character to fourth character so I can do
it by using three.
And no to do it, so it gives me an old space deal.
Now, how do we really check if this is correct or not?
So I'm going from third character.
And when I say I want to see this.
To eat this means that I want to see three, four, five, six and seven characters.
I don't want to see the eight character.
So we are going from three, the third character to the.
Eight one, so it is actually well.
So that's why I am able to see a little space now in case I want to retrieve from, let's say, 30 and
I want to see in the old space the east.
And I don't want to see the space.
I want to see the edge.
Then I would slice it from six to 12 so that I am able to see data from six to 11.
So I'll take it from six and see to it so you can see it goes from space.
Now in case I want to view now, this is a positive direction.
Now, if I want to go from person next to last index, if I want to see the whole data.
I can either simply say X or I can also say X colon, this will mean that I want to start from the very
beginning and go to the very end.
Now, in case I want to see a specific Galleguillos, I want to see the character, then it will show
the character.
Let's say I want to start from second character and I want to give you till the end I can do something
like this.
So it will start from the second character and go to the.
Now, another thing, what I can do is let's say I want to start from edge and I literally want to start
from E, you want to start from E and we want to skip.
One character in between, so we want to see index one, then index three, then index five, then index
seven, then index nine, then index eleven.
Let's say we want to do something like that.
So in that case, we will have to do a subset from one.
Index one to 12.
And we will skip one character in between, so we'll go from.
X one and will go to 11 and we go to 12 here and we want to skip one Galactus, so if we don't want
to skip any character, then we don't not give anything here.
This would mean that we want to see everything now in case I want to skip one more character if I give
a default value one.
This is of equal value one here, so if I give a default value one, it will give me just the same thing.
Now, in case I want to skip one character in between.
I can give one here actually to here.
Then it will skip one character.
Now, in case I want to skip two characters in between so I can give three and it will skip three characters
in between.
So you'll have to experiment this a little bit.
Now what we are simply doing is we are giving the starting point and we are giving the ending point.
And in between we want to skip the character.
So we will see then all.
Then, oh.
Then it's.
Then W.
And then and then so we go from zero to 16.
And then we skipped three values, so that's what we see here, if I begin with one.
You see the data which we've just discussed.
Now, this is in the positive direction, but we do have negative Badakshan indexing also.
So if I do something like this.
Minus one, it was simply the most extreme for me, so the string has been.
Now, if you want to view data in a negative direction, you can use negative indexing.
And for that, you will have to begin from the right side and go to the left side.
To the indexing would also go from live from right to left.
So let's say we want to begin from minus two and we want to go to 60.
So we'll see X.
Minus two.
We are going down in minus 16 and we don't want to skip anything, so we'll just give minus one here.
So this goes in the negative direction.
And if I don't give anything to you, then it would not give anything because it doesn't really understand
that.
So we'll have to give a negative one to you and it will show the values.
If you give one, then it will not really understand what we are trying to do.
So we don't just give nothing you.
So that is how a negative indexing and string slicing work and you can try at the end, you can create
a string and then trying different permutations and combinations and see how slicing works.
Thank you.