0:00:01.010,0:00:02.310 So there are lots more things we can do with 0:00:02.310,0:00:04.760 strings. The next one I am going to talk about, is 0:00:04.760,0:00:08.880 selecting sub-sequences from strings. So what we have seen so 0:00:08.880,0:00:12.500 far, we have used indexing, where we have a string, 0:00:12.500,0:00:15.640 where we have our square bracket. We have some expression 0:00:15.640,0:00:18.880 that produces one number, and we have our closed square 0:00:18.880,0:00:22.760 bracket, and that gives us a one-character string. And whatever 0:00:22.760,0:00:26.160 position the number refers to in the string here. The other 0:00:26.160,0:00:28.310 thing we can do with square brackets is select 0:00:28.310,0:00:30.820 a sub-sequence of the string. Instead of just having 0:00:30.820,0:00:33.930 one expression here, what we can have is an 0:00:33.930,0:00:36.720 expression. This is also something that should evaluate to a 0:00:36.720,0:00:41.800 number, followed by a colon, followed by another expression. 0:00:41.800,0:00:44.810 Both of these expressions are numbers. And this will 0:00:44.810,0:00:49.040 evaluate to a string, this is a subsequence of 0:00:49.040,0:00:51.200 a characters in, the input string. So I called the 0:00:51.200,0:00:54.090 string s, the value of this number will call 0:00:54.090,0:00:56.020 start, and the value of this number will call 0:00:56.020,0:01:00.120 stop. And what the result is, is a string 0:01:00.120,0:01:02.760 that's a subsequence of all the characters in s, 0:01:02.760,0:01:05.570 and the string that we had here. Starting from 0:01:05.570,0:01:08.750 position start, so the number to the left of 0:01:08.750,0:01:13.580 the colon, and ending with position stop, but not 0:01:13.580,0:01:16.830 including that character. So it's going to really include the characters 0:01:16.830,0:01:21.270 from position start, up through stop minus 1. So this construct allows us 0:01:21.270,0:01:25.920 to select from any string A subsequence of continuous characters in that string. 0:01:29.400,0:01:31.450 So, let's try an example in the Python interpreter. 0:01:31.450,0:01:34.080 I'm going to initialize the variable word to be the 0:01:34.080,0:01:37.820 string assume. And using the single index operator we 0:01:37.820,0:01:40.660 saw initially, we can select a character from word. 0:01:40.660,0:01:43.370 So, if I select word index 3. That will 0:01:43.370,0:01:46.520 give us the fourth character, zero, one, two, three, 0:01:46.520,0:01:49.680 which is u, and when we run that, we 0:01:49.680,0:01:53.310 see the result is u. With the new operation, 0:01:54.400,0:01:57.680 that's the same as selecting word 3:4, 0:01:57.680,0:02:01.260 that's going to select starting from position three, going 0:02:01.260,0:02:05.000 to just before position four. So that will end up being just the one letter u. 0:02:06.200,0:02:09.574 Just to make this clear, if I selected 0:02:09.574,0:02:14.820 3:3, there's no string there, that's just a 0:02:14.820,0:02:16.890 single empty string which prints out in a 0:02:16.890,0:02:19.740 way we can't see it. There's no characters 0:02:19.740,0:02:23.430 between 3 and character 3. We'll go back to 0:02:23.430,0:02:27.824 just selecting index 3. I could select from position 4 0:02:27.824,0:02:30.950 through position 6. That would give us a string which 0:02:30.950,0:02:34.552 is a subsequence of letters at position 4 and position 0:02:34.552,0:02:36.380 5. So when we run this now we see the 0:02:36.380,0:02:39.372 first one prints out to u. The second one prints 0:02:39.372,0:02:42.360 out me which is position 4 and position 5. The 0:02:42.360,0:02:44.850 last two characters in the word. I'll show you one 0:02:44.850,0:02:48.550 other thing we can do. Which is, leave one of 0:02:48.550,0:02:52.200 the sides of the colon empty. So it we did 4: 0:02:52.200,0:02:55.250 to the end, that will select from position 4 to the 0:02:55.250,0:02:57.320 end. We don't need to actually count the characters to know 0:02:57.320,0:03:00.050 where the end is. So that will produce the same thing 0:03:00.050,0:03:02.610 as we did before. We can also leave nothing in front 0:03:02.610,0:03:05.520 of the colon. That will select from the beginning. So if 0:03:05.520,0:03:10.140 we do :2, that will select from position 0 up to 0:03:10.140,0:03:17.120 position 2, giving us the first two letters of the word, as. And we could 0:03:17.120,0:03:22.180 leave both sides blank, selecting word, [:], 0:03:22.180,0:03:25.640 with nothing on either side, well, it starts from the beginning, goes to the 0:03:25.640,0:03:28.790 end. That's going to give us the whole word. There's 0:03:28.790,0:03:31.120 no good reason to ever want to do this, but 0:03:31.120,0:03:33.120 it's consistent with the syntax where we can leave 0:03:33.120,0:03:35.260 one side of the colon empty and that means 0:03:35.260,0:03:37.260 selecting from either the beginning or the end.