WEBVTT

00:01.260 --> 00:06.900
Hell, everyone, so in this particular session, we would learn about string slicing and indexing,

00:07.230 --> 00:14.700
so would see how we can retrieve a particular word or a subset of a word using indexing.

00:15.060 --> 00:18.630
So let's I want to get the intent of the word.

00:18.630 --> 00:28.380
I can get that by using land function and applying it on X. So we can see that the length of X is 17

00:28.380 --> 00:29.040
characters.

00:29.280 --> 00:36.750
If I want to retrieve the first character, it would be retrieved by X zero, which is the first index,

00:36.920 --> 00:40.900
the zeroth index, so zero, the Nexus X..

00:41.430 --> 00:45.260
So if I go to one, it is any.

00:47.740 --> 00:53.680
If you go to three, this is L and if you go to 17.

00:55.230 --> 01:04.620
It is because the length of the wood goes from zero to next to 16 Pantex and the length is 17 characters,

01:04.830 --> 01:06.540
so it will go only to 16.

01:07.710 --> 01:12.780
Now, if I want to see the entire world, I can simply see it using X.

01:13.560 --> 01:23.100
Now, if I want to retrieve, let's say, a word from third character to fourth character so I can do

01:23.100 --> 01:25.950
it by using three.

01:27.060 --> 01:32.480
And no to do it, so it gives me an old space deal.

01:32.660 --> 01:35.510
Now, how do we really check if this is correct or not?

01:35.820 --> 01:39.480
So I'm going from third character.

01:39.930 --> 01:42.600
And when I say I want to see this.

01:43.940 --> 01:51.270
To eat this means that I want to see three, four, five, six and seven characters.

01:51.440 --> 01:53.300
I don't want to see the eight character.

01:54.820 --> 01:59.110
So we are going from three, the third character to the.

02:00.490 --> 02:03.290
Eight one, so it is actually well.

02:04.360 --> 02:12.530
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

02:12.570 --> 02:16.690
I want to see in the old space the east.

02:17.050 --> 02:18.630
And I don't want to see the space.

02:18.640 --> 02:19.960
I want to see the edge.

02:20.470 --> 02:28.060
Then I would slice it from six to 12 so that I am able to see data from six to 11.

02:29.650 --> 02:37.620
So I'll take it from six and see to it so you can see it goes from space.

02:39.400 --> 02:43.850
Now in case I want to view now, this is a positive direction.

02:44.140 --> 02:49.390
Now, if I want to go from person next to last index, if I want to see the whole data.

02:50.850 --> 03:00.030
I can either simply say X or I can also say X colon, this will mean that I want to start from the very

03:00.030 --> 03:01.650
beginning and go to the very end.

03:03.070 --> 03:09.880
Now, in case I want to see a specific Galleguillos, I want to see the character, then it will show

03:10.300 --> 03:11.190
the character.

03:11.500 --> 03:17.920
Let's say I want to start from second character and I want to give you till the end I can do something

03:17.920 --> 03:18.580
like this.

03:19.270 --> 03:21.730
So it will start from the second character and go to the.

03:22.970 --> 03:31.070
Now, another thing, what I can do is let's say I want to start from edge and I literally want to start

03:31.070 --> 03:34.640
from E, you want to start from E and we want to skip.

03:35.430 --> 03:42.570
One character in between, so we want to see index one, then index three, then index five, then index

03:42.570 --> 03:46.250
seven, then index nine, then index eleven.

03:46.530 --> 03:48.490
Let's say we want to do something like that.

03:48.720 --> 03:54.330
So in that case, we will have to do a subset from one.

03:55.240 --> 03:57.670
Index one to 12.

03:58.430 --> 04:04.040
And we will skip one character in between, so we'll go from.

04:05.260 --> 04:14.470
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

04:14.470 --> 04:17.210
to skip any character, then we don't not give anything here.

04:17.560 --> 04:22.930
This would mean that we want to see everything now in case I want to skip one more character if I give

04:22.930 --> 04:24.340
a default value one.

04:25.860 --> 04:31.250
This is of equal value one here, so if I give a default value one, it will give me just the same thing.

04:31.470 --> 04:34.180
Now, in case I want to skip one character in between.

04:34.440 --> 04:37.880
I can give one here actually to here.

04:38.130 --> 04:39.690
Then it will skip one character.

04:39.960 --> 04:46.320
Now, in case I want to skip two characters in between so I can give three and it will skip three characters

04:46.320 --> 04:46.830
in between.

04:47.220 --> 04:49.770
So you'll have to experiment this a little bit.

04:50.010 --> 04:54.930
Now what we are simply doing is we are giving the starting point and we are giving the ending point.

04:55.410 --> 04:58.050
And in between we want to skip the character.

04:58.050 --> 05:00.480
So we will see then all.

05:01.930 --> 05:02.640
Then, oh.

05:06.970 --> 05:07.990
Then it's.

05:09.210 --> 05:10.020
Then W.

05:11.360 --> 05:17.720
And then and then so we go from zero to 16.

05:22.020 --> 05:27.960
And then we skipped three values, so that's what we see here, if I begin with one.

05:29.840 --> 05:32.150
You see the data which we've just discussed.

05:32.970 --> 05:37.800
Now, this is in the positive direction, but we do have negative Badakshan indexing also.

05:38.060 --> 05:40.250
So if I do something like this.

05:43.900 --> 05:48.160
Minus one, it was simply the most extreme for me, so the string has been.

05:48.910 --> 05:53.530
Now, if you want to view data in a negative direction, you can use negative indexing.

05:53.740 --> 05:59.050
And for that, you will have to begin from the right side and go to the left side.

05:59.050 --> 06:02.590
To the indexing would also go from live from right to left.

06:02.950 --> 06:07.870
So let's say we want to begin from minus two and we want to go to 60.

06:09.660 --> 06:11.040
So we'll see X.

06:13.210 --> 06:13.950
Minus two.

06:14.710 --> 06:20.960
We are going down in minus 16 and we don't want to skip anything, so we'll just give minus one here.

06:22.150 --> 06:24.400
So this goes in the negative direction.

06:25.590 --> 06:32.160
And if I don't give anything to you, then it would not give anything because it doesn't really understand

06:32.160 --> 06:32.480
that.

06:32.790 --> 06:37.070
So we'll have to give a negative one to you and it will show the values.

06:37.080 --> 06:40.680
If you give one, then it will not really understand what we are trying to do.

06:40.680 --> 06:42.650
So we don't just give nothing you.

06:43.170 --> 06:49.590
So that is how a negative indexing and string slicing work and you can try at the end, you can create

06:49.590 --> 06:55.380
a string and then trying different permutations and combinations and see how slicing works.

06:55.770 --> 06:56.250
Thank you.
