1 00:00:12,170 --> 00:00:19,730 Hello, everybody, this will be the second part of lists topic now once we completed the basics part, 2 00:00:19,730 --> 00:00:22,940 we will head over to the advance spot regarding lists. 3 00:00:23,300 --> 00:00:29,360 And before we begin, I just want to give you a motivation why actually, we need to be masters and 4 00:00:29,360 --> 00:00:30,920 less in this topic. 5 00:00:31,280 --> 00:00:34,490 And we have a really simple reason for that, guys. 6 00:00:35,540 --> 00:00:42,680 Sometimes further on, once we try once we start practicing selenium and start building our automation 7 00:00:42,680 --> 00:00:51,470 end to end solution project, we will encounter elements that have elements meaning items in a website. 8 00:00:51,710 --> 00:00:52,180 All right. 9 00:00:52,460 --> 00:01:01,460 So sometimes we encounter some elements on a website which the identifiers, the ides of several elements 10 00:01:01,460 --> 00:01:02,150 are the same. 11 00:01:02,690 --> 00:01:08,930 And we would like to insert, for example, the text there containing in a list. 12 00:01:09,230 --> 00:01:15,490 So first we will identify them and then we will insert all of the values at once into a list. 13 00:01:15,770 --> 00:01:19,040 So we need to know how to manipulate a list. 14 00:01:19,070 --> 00:01:20,390 I'll give you a quick example. 15 00:01:20,840 --> 00:01:24,020 For example, you see here I have a table, all right? 16 00:01:24,230 --> 00:01:25,220 I have a table. 17 00:01:25,580 --> 00:01:27,230 I'm not going to go to specifics. 18 00:01:27,230 --> 00:01:33,650 I tell you in advance, because we have a lot of hours discussing how to identify elements further on. 19 00:01:33,950 --> 00:01:39,530 But just want to show you that I identified all the items inside this table right here. 20 00:01:39,740 --> 00:01:46,100 And for example, in future lectures, I would like to extract the text all of these cells into a list, 21 00:01:46,100 --> 00:01:47,330 into separate cells. 22 00:01:47,720 --> 00:01:50,980 So starting you see, it's it's marked here. 23 00:01:51,140 --> 00:01:56,090 So starting the first item, then the second and the third and so on. 24 00:01:56,960 --> 00:01:59,630 So for this, I will definitely know. 25 00:01:59,870 --> 00:02:05,490 I definitely need to know how to master list topic to use it. 26 00:02:05,990 --> 00:02:10,810 So this was the motivation part of why do we need lists at all. 27 00:02:11,660 --> 00:02:14,080 So we will use it a lot, believe me. 28 00:02:14,570 --> 00:02:14,890 All right. 29 00:02:14,900 --> 00:02:15,820 So let's begin. 30 00:02:15,890 --> 00:02:23,170 First of all, we declared a list that we will use in this theory, part of advanced list topic. 31 00:02:23,180 --> 00:02:23,510 All right. 32 00:02:23,540 --> 00:02:26,330 So this is this will be our list and let's begin. 33 00:02:26,750 --> 00:02:32,540 So, first of all, I would like to know the length of the list, the number of existing cells. 34 00:02:32,900 --> 00:02:35,930 The countdown starts here from one. 35 00:02:36,350 --> 00:02:41,750 OK, so we have like two topics, so you won't be mixed out with them. 36 00:02:42,420 --> 00:02:43,370 We have the length. 37 00:02:45,210 --> 00:02:45,720 All right. 38 00:02:47,260 --> 00:02:47,890 Count. 39 00:02:49,930 --> 00:02:59,740 Starts from one and we have the index indexes count. 40 00:03:01,000 --> 00:03:02,630 Start from zero. 41 00:03:03,400 --> 00:03:04,360 And what do I mean? 42 00:03:05,020 --> 00:03:08,010 All right, so we want to know the length of the list. 43 00:03:08,020 --> 00:03:13,320 So we just put the key word length, then brackets and put the name of the list inside. 44 00:03:13,510 --> 00:03:17,970 And then once we try to print it, we will get the number four. 45 00:03:18,730 --> 00:03:19,470 And why? 46 00:03:19,960 --> 00:03:24,040 Because once we try to count the number of the cells, you're right. 47 00:03:24,040 --> 00:03:25,120 This is the lank. 48 00:03:25,840 --> 00:03:26,260 All right. 49 00:03:26,260 --> 00:03:27,860 So the count starts from one. 50 00:03:27,880 --> 00:03:28,990 So this will be one. 51 00:03:29,290 --> 00:03:30,280 This will be two. 52 00:03:30,520 --> 00:03:31,460 This will be three. 53 00:03:31,480 --> 00:03:32,750 And this will be four. 54 00:03:33,070 --> 00:03:36,420 So once we try to print it, we'll get the number four. 55 00:03:36,610 --> 00:03:37,120 All right. 56 00:03:37,630 --> 00:03:46,840 And in a difference from the lank, when we want to access the cells, the count starts from zero. 57 00:03:46,870 --> 00:03:47,250 All right. 58 00:03:47,260 --> 00:03:52,000 You you you I'm sure you remember from previous lecture, from previous practice lecture. 59 00:03:52,330 --> 00:03:58,600 Once we want to access this cell, for example, it doesn't start from one star from zero. 60 00:03:58,610 --> 00:04:00,710 So these cells index is zero. 61 00:04:01,030 --> 00:04:09,190 So these two are not connected when counting the length of the of the list will start the count from 62 00:04:09,370 --> 00:04:09,840 one. 63 00:04:09,970 --> 00:04:17,170 But once we want to to address the index is once we want to go into the cells and extract the items, 64 00:04:17,170 --> 00:04:18,940 we will start the count from zero. 65 00:04:21,010 --> 00:04:26,260 All right, so let's go further to the next item. 66 00:04:26,440 --> 00:04:33,250 All right, if you want to change the value of a specific cell inside the list, so let's say we want 67 00:04:33,250 --> 00:04:35,770 to change the value in the cell in cell number one. 68 00:04:35,950 --> 00:04:36,310 All right. 69 00:04:36,320 --> 00:04:38,710 So cell number one is this one. 70 00:04:39,550 --> 00:04:41,970 And all right, it's right here. 71 00:04:42,520 --> 00:04:51,940 So and we want to set the value 10 inside of the cell that currently contains the one hundred and eleven 72 00:04:51,940 --> 00:04:52,640 point nine. 73 00:04:53,110 --> 00:04:55,030 We will just use the following action. 74 00:04:55,030 --> 00:04:57,130 We will state the name of the list. 75 00:04:57,400 --> 00:05:01,810 Then we have square brackets with the number of the cell inside. 76 00:05:02,440 --> 00:05:07,760 OK, and then we have equals and the new value that we want to put there. 77 00:05:08,590 --> 00:05:13,570 So this will replace this value with the value ten. 78 00:05:14,690 --> 00:05:15,590 Pretty easy, right? 79 00:05:16,490 --> 00:05:21,620 All right, so let's go over to the next one once we want to add an item. 80 00:05:22,650 --> 00:05:30,960 To the end of an existing list, so if you recall in the last practice lecture, I gave you a bonus 81 00:05:30,960 --> 00:05:36,590 assignment, which was assignment number eight search in Google, and I promise you that this topic 82 00:05:36,600 --> 00:05:38,410 will be studied in the next video. 83 00:05:38,430 --> 00:05:39,390 So here it is. 84 00:05:39,900 --> 00:05:45,600 And what we want to do here, as is just to add an additional value to the end of the list. 85 00:05:45,960 --> 00:05:55,230 And we saw in the previous practice video that we can use we can achieve it by the apparent action and 86 00:05:55,410 --> 00:05:56,880 we do it in the following way. 87 00:05:57,060 --> 00:06:06,270 We just state we just mentioned the name of the list and then we add that and add the append key action 88 00:06:06,630 --> 00:06:07,320 action word. 89 00:06:07,560 --> 00:06:12,280 And inside the brackets, we're adding the new value that we want to add. 90 00:06:12,510 --> 00:06:14,550 So once we apply this action. 91 00:06:16,250 --> 00:06:25,640 And what what will happen is just we would add a 15 value, a value 15 to the last sell, like an additional 92 00:06:25,640 --> 00:06:28,870 sale will be added and it will contain the value of 15. 93 00:06:29,450 --> 00:06:29,890 All right. 94 00:06:30,350 --> 00:06:30,710 Done. 95 00:06:32,670 --> 00:06:43,410 OK, so next in line is what happens if we want to add an item to a specific cell in the list. 96 00:06:43,440 --> 00:06:43,960 All right. 97 00:06:43,960 --> 00:06:47,850 So we want to add an item to an existing cell. 98 00:06:48,180 --> 00:06:51,010 We just want to add an item to that cell. 99 00:06:51,360 --> 00:06:58,140 So let's say we want to add the number one thousand and five to cell number two. 100 00:06:58,920 --> 00:07:02,130 So we would have to use this action. 101 00:07:02,370 --> 00:07:10,410 Just declaring the list, then using that, then using the keyword insert, then inside the brackets 102 00:07:10,410 --> 00:07:17,070 will put the value that we want to add and then a comma and then then the number of the cell we would 103 00:07:17,070 --> 00:07:25,890 like to add the value to this will cause the existing item of the cell to move forward to the next cell. 104 00:07:26,280 --> 00:07:28,440 So what will happen is the following. 105 00:07:28,440 --> 00:07:31,080 So we were having this list. 106 00:07:32,370 --> 00:07:38,340 And we want to add the number one thousand and five to cell number two, so this is zero, index one 107 00:07:38,340 --> 00:07:38,930 and two. 108 00:07:39,360 --> 00:07:43,530 So what will happen is the following will be added to here. 109 00:07:44,220 --> 00:07:50,210 And the item that was in cell number two would move over to the next cell like this. 110 00:07:50,670 --> 00:07:56,200 So this will be, uh, what will we get after adding to the value one thousand five. 111 00:07:57,540 --> 00:07:57,940 All right. 112 00:07:57,990 --> 00:07:59,880 Breathe easy with the easy guys. 113 00:07:59,880 --> 00:08:04,290 It's not very hard, just some key actions to manipulate. 114 00:08:05,670 --> 00:08:06,150 All right. 115 00:08:06,810 --> 00:08:11,770 So next one is how to remove an item by mentioning the value of it. 116 00:08:11,820 --> 00:08:12,320 All right. 117 00:08:12,540 --> 00:08:15,150 We want to remove a certain value out of the list. 118 00:08:15,270 --> 00:08:19,710 So we just use the remove action key again. 119 00:08:19,980 --> 00:08:25,740 First of all, just by mentioning the name of the list and then DOT and then the keywords remove and 120 00:08:25,740 --> 00:08:31,140 then we state, then the the value that we would like to remove once we apply the S.. 121 00:08:31,350 --> 00:08:38,510 The value 1005 would be removed from the list here before moving to the next one. 122 00:08:38,850 --> 00:08:43,200 Just want to mention that here we stated the value that we would like to remove. 123 00:08:43,800 --> 00:08:50,790 And in the next next item here, we would like to remove an item by mentioning the sale index. 124 00:08:50,820 --> 00:08:51,230 All right. 125 00:08:51,240 --> 00:08:55,350 Here was the value and he would like to use the Salleh index. 126 00:08:55,740 --> 00:09:02,030 So to remove an item by mentioning the sale index, we would like to use the pop action key. 127 00:09:02,400 --> 00:09:02,960 All right. 128 00:09:03,300 --> 00:09:06,710 And we can use the pop by two ways. 129 00:09:07,170 --> 00:09:12,950 First one is mentioning the name of the list, then that and then pop and brackets. 130 00:09:14,160 --> 00:09:17,100 This one would remove the last item. 131 00:09:17,400 --> 00:09:17,980 All right. 132 00:09:18,000 --> 00:09:20,310 This would remove the last item of the list. 133 00:09:20,520 --> 00:09:22,860 This is the opposite of a band, right? 134 00:09:22,920 --> 00:09:24,150 It's its sibling. 135 00:09:24,390 --> 00:09:28,650 Because band will add a value to the end of the list. 136 00:09:28,950 --> 00:09:32,220 It will create a new cell and add a value to it. 137 00:09:32,460 --> 00:09:37,740 But on the other hand, if you use pop, it will remove the last item of the list. 138 00:09:38,100 --> 00:09:38,570 All right. 139 00:09:39,150 --> 00:09:41,250 So this is one way to use it. 140 00:09:41,500 --> 00:09:43,980 And also we have another way to use it. 141 00:09:44,260 --> 00:09:46,590 Also, name of the list that Bob. 142 00:09:47,510 --> 00:09:53,470 All right, and inside the brackets, we can mention the cell that we would like to remove show here, 143 00:09:53,480 --> 00:09:58,940 for example, I would like to remove cell index zero, meaning going up to the list. 144 00:09:58,940 --> 00:10:00,910 I would like to remove the cell completely. 145 00:10:01,130 --> 00:10:05,750 So once remove it, these are the cells that will be remaining at the list. 146 00:10:07,100 --> 00:10:07,520 All right. 147 00:10:07,520 --> 00:10:08,560 So pretty easy. 148 00:10:08,900 --> 00:10:12,740 And this completes the theory part advanced. 149 00:10:12,740 --> 00:10:15,710 Part of this is not very hard. 150 00:10:15,860 --> 00:10:20,120 It's just using some action keys upon a list. 151 00:10:20,300 --> 00:10:24,110 And we will see much examples in the following lectures. 152 00:10:24,280 --> 00:10:28,610 I will show you coding examples of list manipulation. 153 00:10:28,760 --> 00:10:36,140 And afterwards we will head over to the practice part, which you can practice the list at that spot 154 00:10:36,140 --> 00:10:36,580 as well. 155 00:10:36,950 --> 00:10:38,990 And that's about it, guys. 156 00:10:38,990 --> 00:10:40,970 So see you in the next video.