WEBVTT 00:00.490 --> 00:05.440 It in the city let's talk about indexing slicing and negative indexing. 00:05.690 --> 00:10.260 So you know indexing is something to fetch a value for a global vision. 00:10.410 --> 00:17.310 And we already know in the expedition that help us to set a venue Bino you also know the key in exposition. 00:17.310 --> 00:21.720 That means we use a value of key for additional essential value. 00:21.720 --> 00:23.290 The second thing is slicing. 00:23.460 --> 00:26.550 I hope you already know how to slice a piece. 00:26.580 --> 00:29.930 That means taking a piece of a piece up with a list. 00:29.970 --> 00:37.180 We can slice some values maybe I want to slice a value from sinking in exposition to fifth index position 00:37.470 --> 00:40.350 or maybe I want to get the value of the last three. 00:40.350 --> 00:44.500 That is my last three Nicks position so I can do that. 00:44.610 --> 00:48.090 And the last point I want to talk about is negative indexing. 00:48.090 --> 00:53.490 So we have a positive index for a sequence like if for example of my spring. 00:53.550 --> 00:59.690 I have a python string and I get a positive index for B zero for y. 00:59.700 --> 01:01.760 It's one for B it's two. 01:01.820 --> 01:07.370 So that's follow up with the index but there is also something like negative in x. 01:07.380 --> 01:14.630 So the last value that is presented in my string is minus one and the single last value is minus 2. 01:14.850 --> 01:19.350 So if I follow that the first value B is minus 6. 01:19.350 --> 01:25.680 So I need to keep in mind it's really helpful to convert my spring into reverse or to convert any of 01:25.680 --> 01:33.540 my sequence into the words and slice some values that means the copies of them that I hope now you know 01:33.600 --> 01:35.310 the meaning of these ten. 01:35.470 --> 01:38.860 Let's perform their examples and do things step by step. 01:39.080 --> 01:42.960 So the first thing that I want to talk about is start instead. 01:43.230 --> 01:50.250 So if I want to slice any particular list or a particular one on my string I have to pass these three 01:50.250 --> 01:53.390 values on a star instead. 01:53.670 --> 01:55.570 Let me take that for my list. 01:55.590 --> 02:01.650 So where is my X and if I want to set a value of an index I use 0. 02:01.790 --> 02:04.790 So suppose I want to get the value of my zero index. 02:04.950 --> 02:06.640 But what if I need to slice. 02:06.780 --> 02:12.200 That means I need to slice from zero in exposition to 30 next position. 02:12.330 --> 02:18.260 So what I need is I need to move all on and then pass mine end of slice. 02:18.270 --> 02:20.990 So that would be code in exclusion. 02:21.030 --> 02:22.810 So this is my starting position. 02:22.830 --> 02:24.460 This is my position. 02:24.600 --> 02:31.350 And then I need to pass steps which steps are basically the gap that we need to maintain between every 02:31.350 --> 02:32.140 position. 02:32.280 --> 02:37.750 So by default it's one that means say Vinings next with this and next will be one. 02:37.740 --> 02:39.750 Next we'll be going actually with three. 02:39.790 --> 02:46.280 So that is the gap I need to pass that top stop in and then my steps in this one 02:53.260 --> 02:59.520 you can see I was able to slice my menu my stop position my position and then stamped. 02:59.540 --> 03:04.120 So remember the position we are passing for our end will not be in play. 03:04.250 --> 03:08.810 So I got my 0 1 2 and tardos not included. 03:08.870 --> 03:10.000 This looks fine. 03:10.040 --> 03:15.010 Let me try out something more what if I don't. 03:15.240 --> 03:20.220 I also start and then let me play this one. 03:20.250 --> 03:25.780 You can see I still got the same result because the default value of 4 gap is 1. 03:25.980 --> 03:27.880 So it's not going to affect that much. 03:28.140 --> 03:35.270 But what if I need to get from one to end of that list maybe I want to start with a default position 03:35.400 --> 03:37.040 and then the end of the list. 03:37.200 --> 03:38.010 We can do that. 03:38.010 --> 03:41.700 All we have is a blank space for a second position. 03:41.700 --> 03:43.570 Remember to use the school. 03:43.730 --> 03:47.330 So without the score on it would be 0 in the exposition. 03:47.390 --> 03:49.000 What does it mean. 03:49.020 --> 03:51.650 It will be starting from this position 11. 03:51.820 --> 03:59.160 So if I pass up four and then a call on that means Trump for the next position in the end if we print 03:59.160 --> 04:05.540 this one you can see I was able to fetch the values from the next position in the last. 04:05.720 --> 04:06.090 OK. 04:06.120 --> 04:07.770 Let me experiment more. 04:07.800 --> 04:13.110 What if I want to get the values from zero to most left. 04:13.160 --> 04:14.470 You can also do that. 04:14.510 --> 04:21.100 All they have to do is just leave out the four spaces blank and then the next when you. 04:21.130 --> 04:22.020 This looks fine. 04:22.100 --> 04:24.690 Let me bring this out also. 04:24.740 --> 04:27.660 You can see I was able to get the values from zero. 04:27.700 --> 04:29.640 All my fault index Felician. 04:29.750 --> 04:32.010 Remember this would not be included. 04:32.210 --> 04:35.420 Now what if I need to get a complete value of this list. 04:35.420 --> 04:36.590 You can also do that. 04:36.650 --> 04:41.910 All we have to lose was in the value what are starting as well as ending. 04:41.990 --> 04:44.240 And then what are steps are by default. 04:44.390 --> 04:46.800 So this would be from start to end. 04:47.810 --> 04:52.680 And I don't know I got a complete list. 04:52.680 --> 04:54.650 So that's how I slicing work. 04:54.870 --> 04:59.060 But what is the matter of the steps against me with that. 04:59.440 --> 05:01.750 What if I need to get a gap of two 05:04.540 --> 05:08.500 so basic they need to Mandino gabble to we know that is us. 05:08.540 --> 05:10.500 Maybe I just want a zero next position. 05:10.510 --> 05:17.410 And again next Felician then for the next Felician I can still achieve that oh let me try this one. 05:18.640 --> 05:21.670 And Hagens I was able to keep the gap off. 05:22.190 --> 05:24.590 Let me try out a gap of three. 05:24.800 --> 05:31.390 On this one and see I was able to maintain the gap octree So that's slicing work and this really really 05:31.390 --> 05:32.670 important. 05:32.800 --> 05:38.340 We have on the trial with was the day when next thing we should try out our negative index also. 05:38.500 --> 05:41.890 So the negative next actually is follow up with the reverse order. 05:42.040 --> 05:46.430 So the last item will the minus one day minus two minus three four. 05:46.540 --> 05:47.890 And then follow up. 05:48.010 --> 05:55.530 Let me clear this up and if I want to achieve the reverses and all I have to do is Baso minus one and 05:55.530 --> 05:56.160 the last. 05:56.290 --> 06:05.030 So this will bring down my list in reverse order if I print that I got my list as a reverse order. 06:05.370 --> 06:07.610 You can also play with a lot more thing. 06:07.830 --> 06:12.710 Well let me talk about one simple thing I would be taking this Python example. 06:15.830 --> 06:18.930 I'm getting a result of reversals by Tom. 06:19.130 --> 06:26.880 What if I need to get nost three elements of my string or off my list or off my dog when I can do that. 06:26.970 --> 06:31.560 If we remove this one so last element means I need to get these three. 06:31.610 --> 06:36.650 That is etched all add to my list will we start from minus three. 06:36.680 --> 06:41.220 I need to get that and we end the last. 06:41.370 --> 06:44.370 So if I give minus 1 to this would not be included. 06:44.450 --> 06:46.180 So I need to lead this is a blank. 06:46.190 --> 06:48.750 And then all this will be one step. 06:48.890 --> 06:51.520 This looks fine on this one. 06:52.150 --> 06:57.960 I get it all in now seem things without indexing. 06:58.010 --> 07:02.440 So usually with indexing if I pass a zero I will be getting a B. 07:02.720 --> 07:10.410 But if I pass a minus 6 with my mixing you can see I still want the same result because 0 is B and minus 07:10.410 --> 07:11.710 6 is also be. 07:11.760 --> 07:19.690 So we can play with negative value during indexing Also I had a hard concept you can probably string 07:19.690 --> 07:26.260 or double Also you need to be focused while passing notes start in and then you see if you are passing 07:26.320 --> 07:30.610 three as a start to tell you the ending really should be greater than in the whole region. 07:30.790 --> 07:34.560 That means if you're passing three the ending really should be about three. 07:34.600 --> 07:40.570 You can get past three and then one since it will not go in reverse to go in reverse. 07:40.570 --> 07:41.810 We use minus one. 07:41.830 --> 07:46.340 That means if I need to get a value of h e y. 07:46.420 --> 07:49.770 So my starting lose three that's required. 07:49.780 --> 07:51.380 My ending is 1. 07:51.400 --> 07:55.780 This is also fine if I want to take four steps. 07:55.800 --> 07:59.160 That is if a big step is one I would go forward. 07:59.220 --> 08:02.630 But if I did step in minus one I would go in reverse. 08:02.820 --> 08:05.750 And now let me run this one. 08:05.880 --> 08:12.220 You can see I was able to achieve the value from my list if I try this with. 08:15.230 --> 08:18.260 You get an even bigger the value of h in D. 08:18.500 --> 08:24.740 So basically this is an important concept if you can't understand this you're slicing this or you can 08:24.860 --> 08:28.830 slice anything from less from table from string. 08:28.850 --> 08:31.900 So the thing is the number you stop will you. 08:32.030 --> 08:36.560 You're ending Melu should be greater than that if you're taking a step as positive. 08:36.680 --> 08:43.940 So if my boss of a loved one as a starting and if I end ended at 3 that's looks fine because I can take 08:43.940 --> 08:46.310 one and do with a positive step. 08:46.490 --> 08:54.860 But what if if I pass four as my starting value and then I'm passing one as my ending value that means 08:54.860 --> 09:00.500 I can not take step as plus one plus one step means I'm jumping from four to five. 09:00.740 --> 09:07.870 I need two big minus one to jump from four to three in two to do them to one that is going to fold here. 09:07.980 --> 09:11.680 So if I take four and then I won the value then why. 09:11.690 --> 09:15.550 So I will be taking zero as index and then minus one. 09:16.160 --> 09:19.790 Four is the value of all I'm ending the zero. 09:19.790 --> 09:26.000 That means still wide we're being great and I'm digging in a river so I'm getting a result of zero h 09:26.120 --> 09:28.390 d in my. 09:28.510 --> 09:29.490 This looks fine. 09:29.490 --> 09:32.740 Let me run this one yeah. 09:32.900 --> 09:39.560 That's how you can set your value and that's the reason if I'm passing empty space and just minus one 09:40.280 --> 09:43.890 that means I'm going to get a result of newsboy's. 09:43.970 --> 09:45.550 So that's all for this lecture. 09:45.650 --> 09:53.180 Indexing slicing and negative indexing these trees are really really important to fetch values from 09:53.180 --> 09:54.300 my storage. 09:54.320 --> 09:56.560 I hope I know you understand about them. 09:56.570 --> 10:00.890 These are some really important topics and we'll be dealing with more letters. 10:00.890 --> 10:01.850 Thank you for calling. 10:01.850 --> 10:06.000 All of us to now see you in the next one with a lot more stuff.