1 00:00:00,270 --> 00:00:02,520 Hello everybody and welcome back. 2 00:00:02,520 --> 00:00:09,900 And in this story all will cover something called lists now basically lists is as it says it can be 3 00:00:09,900 --> 00:00:14,580 used to store for example multiple values of a number or a string. 4 00:00:14,580 --> 00:00:20,320 So let's say you for example wanted to store three different numbers into one variable. 5 00:00:20,320 --> 00:00:26,310 You would do that using lists so you would specify all those three numbers in all those brackets divided 6 00:00:26,310 --> 00:00:27,560 by commas. 7 00:00:27,600 --> 00:00:31,470 We already saw an example of creating a list in the previous videos. 8 00:00:31,470 --> 00:00:35,820 But right now let's see what we can do with lists and how to create them. 9 00:00:35,880 --> 00:00:40,530 So let's open up our Python interpreter so just typed your python. 10 00:00:40,530 --> 00:00:46,340 And right now what you want to do is basically let's first of all create a string list. 11 00:00:46,350 --> 00:00:51,950 So a string list is basically a list containing words. 12 00:00:52,020 --> 00:00:56,670 There is not really any special specification for that to use one type here. 13 00:00:56,670 --> 00:00:59,190 String lists or basically name it anything you want. 14 00:00:59,190 --> 00:01:05,310 I will just name it string list equals then these kinds of brackets and then what you need to specify 15 00:01:05,400 --> 00:01:10,200 here is basically just the strings that you want to put in the list. 16 00:01:10,200 --> 00:01:26,160 So let's say we put right here shallow comma and then world comma then open bracket then open a repository 17 00:01:26,160 --> 00:01:26,670 once again. 18 00:01:26,670 --> 00:01:39,540 So what closed the apostrophe open apostrophe what is happening and then we close the bracket. 19 00:01:39,540 --> 00:01:42,050 So right now we specified a list. 20 00:01:42,060 --> 00:01:50,030 So let's print it out string list and you can see the values of our string list which is how the world 21 00:01:50,190 --> 00:01:51,410 what is happening. 22 00:01:51,570 --> 00:01:54,540 So let's see what we can do with lists. 23 00:01:54,540 --> 00:02:03,360 For example you can select each part of the list or each value of the list by specifying its number. 24 00:02:03,360 --> 00:02:09,050 So if you for example specify string list and then in brackets one. 25 00:02:09,180 --> 00:02:12,840 So just like this string list don't make space between these two. 26 00:02:12,840 --> 00:02:19,440 Just type here these brackets and then 1 it will print out the second version or the second word in 27 00:02:19,440 --> 00:02:21,400 our list which is world. 28 00:02:21,450 --> 00:02:28,170 Now you might be asking why does it print the second word in our list if we specified one in the brackets. 29 00:02:28,170 --> 00:02:32,040 Well basically this is counted as the zero word it car. 30 00:02:32,060 --> 00:02:33,780 It starts counting from zero. 31 00:02:33,780 --> 00:02:34,880 So this is zero. 32 00:02:34,890 --> 00:02:37,030 This is one this is two. 33 00:02:37,110 --> 00:02:39,070 This is three and this is four. 34 00:02:39,120 --> 00:02:41,740 That's why we got the word world. 35 00:02:41,790 --> 00:02:44,650 Once we specify the one in our brackets. 36 00:02:44,790 --> 00:02:52,320 If we for example specify zero we would get the shallow words in our list so you can specify that. 37 00:02:52,390 --> 00:02:58,360 You can also specified for example one and then two dots which will specify all the words from one to 38 00:02:58,720 --> 00:02:59,410 the end. 39 00:02:59,470 --> 00:03:03,870 These two dots represent the end of the list as we can see we have right now. 40 00:03:04,000 --> 00:03:11,230 World what is happening there is no where to see yellow since yellow is before 1 if you specified three 41 00:03:11,680 --> 00:03:17,810 and then two dots equals print out everything from the Third Word which in our case is is. 42 00:03:17,860 --> 00:03:22,180 So it prints out just is happening. 43 00:03:22,180 --> 00:03:27,940 You can also do it the other way around so you can just type first the two dots and then after that 44 00:03:27,940 --> 00:03:34,590 three which I'll specify or which will print out all the words before the third word so we will long 45 00:03:34,590 --> 00:03:36,490 forget how the world what. 46 00:03:36,610 --> 00:03:40,060 And we will not be printing out what is happening after that. 47 00:03:40,060 --> 00:03:46,920 So that is another string or list manipulation you can use this can also be applied for string. 48 00:03:46,920 --> 00:03:52,210 So for example let's just select a string to be hello. 49 00:03:52,510 --> 00:03:57,810 And then if you just type your string one you will get the letter E. 50 00:03:58,030 --> 00:04:03,280 If you just type your string and then one and then until the end which is packed with these two dots 51 00:04:03,280 --> 00:04:11,080 right here you will get Ello right now since we only specified all the letters after the first one including 52 00:04:11,080 --> 00:04:11,650 the first one. 53 00:04:11,650 --> 00:04:15,270 So h as a number 0 letter will not be included in this. 54 00:04:15,280 --> 00:04:21,580 You can also do it as it set in the reverse way so let's say until two we only get h e so this can be 55 00:04:21,580 --> 00:04:25,360 implied both for strings and both for lists. 56 00:04:25,360 --> 00:04:31,000 Now this is important to remember the syntax for this since we will be using it also in our backdoor 57 00:04:31,000 --> 00:04:31,660 creation. 58 00:04:32,110 --> 00:04:36,400 So that is something you should know but right now let's get back to the list. 59 00:04:36,400 --> 00:04:45,200 So let's be clear the screen right a little bit so input so that soil system cleared. 60 00:04:46,230 --> 00:04:51,030 And right now let us find the commando specification for our string list. 61 00:04:51,040 --> 00:04:51,740 So here it is. 62 00:04:51,760 --> 00:04:53,580 We specified once again. 63 00:04:53,640 --> 00:05:00,340 Now let's see for example how we can remove a certain letter from B or not better a certain string from 64 00:05:00,400 --> 00:05:01,720 our list. 65 00:05:01,870 --> 00:05:10,630 You can do that with using this so string list we specify the name of our list and then dot remove and 66 00:05:10,630 --> 00:05:16,390 then open normal brackets and then between the double quotes we specify the word that we want to remove. 67 00:05:16,420 --> 00:05:21,730 So let's say we want to remove the world and we press here enter. 68 00:05:21,760 --> 00:05:27,730 And if you just type your string list once again so string list you will see right now our list doesn't 69 00:05:27,730 --> 00:05:29,270 have world in it. 70 00:05:29,470 --> 00:05:33,630 We only have yellow what is happening right now. 71 00:05:33,710 --> 00:05:36,320 We do not have the world in our list. 72 00:05:36,350 --> 00:05:41,150 So that is how you can remove it. 73 00:05:41,150 --> 00:05:48,080 And right now if you specify a string a list of one you will no longer get the world as a word since 74 00:05:48,080 --> 00:05:54,460 right now the first word which is since it's counted from zero is what and not world anymore. 75 00:05:54,560 --> 00:05:57,450 So that is another thing you should know. 76 00:05:57,590 --> 00:06:04,490 Now for example if you want to append something to the list you can use the dot append command and then 77 00:06:04,490 --> 00:06:10,970 the name or the string that you want to append to but be aware that this will only add the word or your 78 00:06:10,970 --> 00:06:13,100 string to the end of the list. 79 00:06:13,100 --> 00:06:16,070 So if we wanted to add world once again. 80 00:06:16,070 --> 00:06:24,910 So string underscore list which is name dot append open brackets close brackets and then to double quotes 81 00:06:24,910 --> 00:06:25,440 in here. 82 00:06:25,460 --> 00:06:27,960 We want to add world we press enter. 83 00:06:28,040 --> 00:06:32,620 But right now if we just type your string list once again you will see that right now it says hello 84 00:06:32,630 --> 00:06:34,400 what is happening world. 85 00:06:34,400 --> 00:06:39,440 The world is no longer in the second position now or list it is at the last position in our list. 86 00:06:39,440 --> 00:06:41,680 So not append is used. 87 00:06:41,720 --> 00:06:49,340 Once you want to know to actually add a string to the end of the list now in order to remove a string 88 00:06:49,340 --> 00:06:56,570 from the end of the list you can use dot pop which basically just opps or removes the last word into 89 00:06:56,570 --> 00:06:56,900 left. 90 00:06:56,930 --> 00:07:02,640 So string list dot pop and then open brackets right here. 91 00:07:02,660 --> 00:07:07,630 You do not need to specify anything basically since it will remove the last string from list. 92 00:07:07,630 --> 00:07:15,860 You just press your enter and it will pop up the world string so string list once again and we no longer 93 00:07:15,860 --> 00:07:18,150 have the world string in it. 94 00:07:18,170 --> 00:07:19,280 We popped it up. 95 00:07:19,280 --> 00:07:21,530 We did dot pop function. 96 00:07:21,530 --> 00:07:26,570 Now function is also something that we will have to cover since we will be making our own functions 97 00:07:26,570 --> 00:07:27,870 in our program. 98 00:07:27,890 --> 00:07:33,410 So that is something that we will do in the next video functions are very important especially once 99 00:07:33,410 --> 00:07:36,840 you code are bigger problem programs it. 100 00:07:36,990 --> 00:07:44,030 They're useful for us to actually navigate better travel code and to actually shorten our code a little 101 00:07:44,030 --> 00:07:44,290 bit. 102 00:07:44,300 --> 00:07:49,400 Once you use a function you can only call it with one line and you do not need to rewrite it 10 times 103 00:07:49,400 --> 00:07:52,240 in order to perform the same task for something. 104 00:07:52,340 --> 00:07:56,610 So that would be about it for the lists in this area. 105 00:07:56,990 --> 00:08:00,100 As I said in the next one we will be covering functions. 106 00:08:00,090 --> 00:08:03,020 So I hope I see you there and take care by.