1 00:00:00,880 --> 00:00:01,320 Hello guys. 2 00:00:01,360 --> 00:00:06,080 Welcome back to another class of our course about Python. 3 00:00:06,100 --> 00:00:12,400 So until now we talked about a lot of interesting things which are variables we talked about data that 4 00:00:12,400 --> 00:00:13,830 you can store in your variables. 5 00:00:13,840 --> 00:00:16,670 We created apps to put everything together. 6 00:00:16,790 --> 00:00:21,460 And until now you have small but pretty good knowledge of python. 7 00:00:22,330 --> 00:00:28,690 So in this class we are still going to continue talking about data up data manipulation. 8 00:00:28,720 --> 00:00:35,110 So my goal right now is to show you another way that you guys can store your data so you can store your 9 00:00:35,110 --> 00:00:40,920 data into a variable so we can store in number a string or a boolean instead of a variable. 10 00:00:41,050 --> 00:00:44,860 But let's say you want to store a bunch of data at the same place. 11 00:00:45,430 --> 00:00:50,470 So this is where lists come into play. 12 00:00:50,470 --> 00:00:55,930 The list is simply a variable where we can store more than let's say one data. 13 00:00:55,930 --> 00:01:05,560 So let's say for example let's take a variable so I'll write down here variable one and the variable 14 00:01:05,560 --> 00:01:06,220 one. 15 00:01:06,220 --> 00:01:08,190 Let's say I want to store a string instead of it. 16 00:01:08,200 --> 00:01:18,660 So let's say I store Apple so you can see my variable number one has only one element in it. 17 00:01:18,760 --> 00:01:21,110 So it has only one string. 18 00:01:21,310 --> 00:01:23,350 But let's say I want to create a list. 19 00:01:23,410 --> 00:01:24,430 So in this case I'll write. 20 00:01:24,430 --> 00:01:25,680 Don't list one. 21 00:01:25,720 --> 00:01:32,170 It starts the exact same way but right now to write down my list what I'm what I need to do is open 22 00:01:32,170 --> 00:01:40,700 up those special parentheses and I can start writing down the all the all the other ones that will be 23 00:01:40,740 --> 00:01:41,470 my list. 24 00:01:41,470 --> 00:01:48,020 So let's say I have apples I have bananas I have. 25 00:01:48,310 --> 00:01:49,000 And then this 26 00:01:52,310 --> 00:01:54,490 and I have melon. 27 00:01:54,500 --> 00:01:56,760 So fruits. 28 00:01:57,320 --> 00:01:58,530 All right. 29 00:01:58,970 --> 00:02:03,850 So as you can see if for example I decide to print the whole list. 30 00:02:03,860 --> 00:02:08,620 So in this case it will be list 1. 31 00:02:08,660 --> 00:02:14,930 So what will happen is that python will print the whole list as you can see I have my four of my four 32 00:02:15,020 --> 00:02:18,020 elements right here which is apple banana and on us and melon. 33 00:02:18,770 --> 00:02:25,250 But let's say right now I want to work with my list and I want to print only one of those elements so 34 00:02:25,250 --> 00:02:29,660 in this case let's say I want to print only Apple. 35 00:02:29,660 --> 00:02:36,260 So the way I explained you guys Python works Python well in this case python will use indexes but how 36 00:02:36,260 --> 00:02:38,500 indexes work is very simple. 37 00:02:38,540 --> 00:02:41,830 The first element is always the element 0. 38 00:02:41,840 --> 00:02:44,570 So in this case Apple will be equal to zero. 39 00:02:44,600 --> 00:02:49,130 Banana will be equal to one and S will be equal to two and million will be equal to three. 40 00:02:49,880 --> 00:02:55,720 So let's say I want to print the first element which here will be the element 0. 41 00:02:55,760 --> 00:03:00,020 So how I will do this I will write down my friend function. 42 00:03:00,020 --> 00:03:04,880 Then I write down the name of the list for the variable that I want to print. 43 00:03:05,130 --> 00:03:10,080 And in the case that if it's a list I will still open up my parentheses. 44 00:03:10,340 --> 00:03:13,280 And in this case I will select the number zero. 45 00:03:13,280 --> 00:03:19,990 So let's say I want to print Apple so I will simply write down zero which is the index value of Apple. 46 00:03:20,270 --> 00:03:22,100 And as you can see I just print that out. 47 00:03:22,110 --> 00:03:32,740 Apple if only print out banana in this case I will simply write down number one and I printed test and 48 00:03:32,770 --> 00:03:37,630 see it writes down banana all right. 49 00:03:37,660 --> 00:03:41,620 So right now you know exactly how you can select the right value to print. 50 00:03:41,620 --> 00:03:44,140 So let's say for example Apple banana or us. 51 00:03:44,230 --> 00:03:47,650 You simply write don't print you write down your list. 52 00:03:47,660 --> 00:03:53,110 So in this case list number one and you select the index value that you want to print. 53 00:03:53,110 --> 00:03:57,640 So you want to print number one number zero one two three. 54 00:03:57,670 --> 00:04:02,310 Next thing let's say for example right now that you want to modify what's in here. 55 00:04:02,320 --> 00:04:05,330 So in this case for example we have Apple we have banana and we have a.. 56 00:04:05,350 --> 00:04:08,220 But let's say I want to change melon by. 57 00:04:08,440 --> 00:04:14,050 I don't know avocado so in this case what I will do it is very simple. 58 00:04:14,150 --> 00:04:24,280 So I write down my list one and I will open up my parenthesis and then this case I will select the index 59 00:04:24,280 --> 00:04:27,700 of melons or melon will be the third index. 60 00:04:27,700 --> 00:04:29,030 I write down equal. 61 00:04:29,050 --> 00:04:34,650 And by and I write down by what exactly I want to change melons so in this case I want a change melon. 62 00:04:34,670 --> 00:04:43,060 But full cattle then when it's all done you can simply print this let's say in this case I print this 63 00:04:52,860 --> 00:04:53,930 so list 64 00:04:56,860 --> 00:04:57,340 65 00:05:04,170 --> 00:05:06,600 and as you can see here it all changes. 66 00:05:06,600 --> 00:05:08,160 So I have apple I have banana. 67 00:05:08,160 --> 00:05:15,930 I have an illness and I have avocado instead of melon because I just changed my Yeah well my my element 68 00:05:15,930 --> 00:05:16,920 right here which is melon. 69 00:05:16,920 --> 00:05:18,390 I change it by avocado. 70 00:05:18,420 --> 00:05:23,460 I can't do it on multiple elements so let's say for example I want to change the element number two 71 00:05:23,460 --> 00:05:25,580 as well so you can just write down list. 72 00:05:26,190 --> 00:05:32,110 So list one and I changed the element number two which is unless I can change it by I don't know to 73 00:05:32,100 --> 00:05:32,370 me. 74 00:05:33,570 --> 00:05:42,530 So in this case I'll change you by to model and if I print list one once again you'll be able to see 75 00:05:42,530 --> 00:05:45,010 apple banana to me you and avocado. 76 00:05:45,600 --> 00:05:49,600 So as you can see guys it's very very simple to use. 77 00:05:49,610 --> 00:05:52,590 So this is a way that you guys can print. 78 00:05:53,130 --> 00:05:56,360 You can print elements so you can see it's very very simple too. 79 00:05:56,390 --> 00:05:59,850 Well very simple to work with lists in the basic ways. 80 00:05:59,990 --> 00:06:04,010 If you want to select an element and if you want to modify an element. 81 00:06:04,010 --> 00:06:04,340 All right. 82 00:06:04,340 --> 00:06:12,190 Another thing that you guys can do with lists in this case would be selecting only one of the elements 83 00:06:12,280 --> 00:06:14,920 or multiple elements but not all elements. 84 00:06:14,920 --> 00:06:18,280 So let's say for example right here I have more than four elements. 85 00:06:18,280 --> 00:06:19,860 Let's say I want to have. 86 00:06:20,140 --> 00:06:24,070 So I have apple bananas and a nice melon strawberry 87 00:06:29,710 --> 00:06:30,910 and other 88 00:06:34,250 --> 00:06:34,660 right. 89 00:06:35,980 --> 00:06:41,860 And right now I only want to have the element number let's say two. 90 00:06:41,890 --> 00:06:42,850 So banana. 91 00:06:43,330 --> 00:06:46,120 So how exactly I will do this exact same thing. 92 00:06:46,120 --> 00:06:47,970 So simply I will print. 93 00:06:48,040 --> 00:06:54,710 So I use my print function I write down list number one. 94 00:06:54,720 --> 00:07:02,730 So in this case list number one and I open up my special parentheses and I write down so what I said 95 00:07:02,820 --> 00:07:05,550 is I want my banana. 96 00:07:05,550 --> 00:07:15,240 I want my N.A. so banana is the number one and an S is number two in our Python index. 97 00:07:15,250 --> 00:07:20,290 So what I want to write is from 1 to 3. 98 00:07:20,290 --> 00:07:26,740 So what's going to happen here is that python will give me will return the number one and the number 99 00:07:26,740 --> 00:07:29,240 two but will not return me the number three. 100 00:07:29,290 --> 00:07:31,520 So let's say I print everything right here. 101 00:07:31,600 --> 00:07:38,890 So I have my banana and my N.A. if I want for example to print that my banana my antennas and my melon. 102 00:07:38,920 --> 00:07:42,310 In this case is going to be from 1 to 4. 103 00:07:42,910 --> 00:07:43,750 And if I print it. 104 00:07:44,260 --> 00:07:46,690 Well as you can see I will have banana and an S and melon. 105 00:07:47,020 --> 00:07:50,350 But let's say I want to print everything but not the apples. 106 00:07:50,380 --> 00:07:53,470 In this case I can just write it down like this. 107 00:07:53,500 --> 00:07:59,500 So it's gonna be print list one and two points and they leave it empty as you can see it's gonna print 108 00:07:59,560 --> 00:08:00,470 absolutely everything. 109 00:08:00,580 --> 00:08:08,600 If I start printing from an n as well in this case I can just write them too because it's gonna be index 110 00:08:08,600 --> 00:08:17,380 zero index 1 and index 2 and I start to print from index 2 and index 2 is included so I'll have an A.M. 111 00:08:17,380 --> 00:08:24,010 melon strawberry and other so you can see this is a basic manipulation of lists and what exactly you 112 00:08:24,010 --> 00:08:24,960 can do with it. 113 00:08:25,180 --> 00:08:29,580 And as you can see it's not that hard to do and it's not that hard to use. 114 00:08:30,900 --> 00:08:35,500 Well as I explained if we summarise absolutely everything difference between the list and a variable 115 00:08:35,500 --> 00:08:38,190 is that a variable will have only one element in it. 116 00:08:38,230 --> 00:08:43,930 It could be a string could be a boolean it could be a number but in the case of a list it's a it's absolutely 117 00:08:44,020 --> 00:08:44,710 different. 118 00:08:44,890 --> 00:08:52,780 You can have all the trees so we can have numbers boolean and strings and what is school is that you 119 00:08:52,780 --> 00:08:55,570 can work with all those at the same time. 120 00:08:55,570 --> 00:09:03,860 So at the same time you can select one of those and you can work just with this only element. 121 00:09:03,910 --> 00:09:10,090 So right now you know the basics of lists in the future we are going to talk about more advanced functions 122 00:09:10,720 --> 00:09:12,590 about all those lists as well. 123 00:09:12,730 --> 00:09:15,820 So that's it for the sports guys and see out in our next class.