1 00:00:00,850 --> 00:00:09,010 You can add a new element at any position in your list by using the insert insert method. 2 00:00:09,370 --> 00:00:14,950 You do this by specifying the index of the new element and the value of the new item. 3 00:00:14,950 --> 00:00:19,330 In this case, we will make the auxiliary courses that insert here. 4 00:00:19,330 --> 00:00:20,980 First, we will enter the index. 5 00:00:20,980 --> 00:00:29,320 In this case, let's actually add two zero the first index here, and after that we will enter the value. 6 00:00:29,320 --> 00:00:34,240 In this case, let's actually make the let's add new course, the courses list. 7 00:00:34,750 --> 00:00:42,940 And in this case, we will add the computer forensics course and that's it. 8 00:00:43,120 --> 00:00:47,980 So now we will print the auxiliary courses. 9 00:00:47,980 --> 00:00:55,660 And here, as you can see here, under coding training in 33 hours specified and course in the world. 10 00:00:55,660 --> 00:00:58,840 And lastly, we will have here. 11 00:00:59,800 --> 00:01:00,060 Oops. 12 00:01:01,060 --> 00:01:01,730 Combative ranks. 13 00:01:01,750 --> 00:01:10,990 Now, of course, we want to this year, the first year we added the first index with this zero here. 14 00:01:11,170 --> 00:01:19,870 So in this example, we insert a value computer forensics course at the beginning of the list. 15 00:01:19,870 --> 00:01:30,130 So the insert method opens a space position at the zero and stores the value computer forensics course 16 00:01:30,250 --> 00:01:31,090 at here. 17 00:01:31,090 --> 00:01:34,990 So, for example, let's make sure here we. 18 00:01:36,170 --> 00:01:38,710 Oops, let's actually use the boxes. 19 00:01:38,720 --> 00:01:40,670 So one, two, three, four. 20 00:01:40,670 --> 00:01:42,740 We have four boxes, right? 21 00:01:45,720 --> 00:01:46,550 Three. 22 00:01:50,400 --> 00:01:51,990 So here. 23 00:01:53,360 --> 00:02:00,920 If you write like that, it will add the our new value to here and. 24 00:02:02,330 --> 00:02:08,360 Our index Android here is going to be one now from now on here. 25 00:02:09,570 --> 00:02:16,890 Our index Android is going to be one, two, three, four and the newly added. 26 00:02:18,180 --> 00:02:21,360 Computer forensics course is going to be what? 27 00:02:21,570 --> 00:02:22,350 Yes. 28 00:02:22,380 --> 00:02:23,010 Zero. 29 00:02:23,520 --> 00:02:32,010 And as you can see here, this this course is splitted like this, this increase it by one because of 30 00:02:32,010 --> 00:02:33,450 the we added here. 31 00:02:33,600 --> 00:02:43,650 So this operations shifts every other value in the list one position to the right here. 32 00:02:43,980 --> 00:02:47,310 So we can also remove elements from a list. 33 00:02:47,310 --> 00:02:52,200 So actually let's try another example now here one right. 34 00:02:52,230 --> 00:02:53,610 Let's try this now. 35 00:02:54,340 --> 00:02:58,990 And here now we will create the same illustration here. 36 00:02:59,080 --> 00:03:03,730 In this case, for example, one, two. 37 00:03:05,890 --> 00:03:06,670 Three. 38 00:03:08,450 --> 00:03:09,290 All right. 39 00:03:10,260 --> 00:03:14,040 So here we add a new element here. 40 00:03:14,040 --> 00:03:14,650 Right? 41 00:03:14,670 --> 00:03:21,750 So now, from now on, our new element will be added at the here, right? 42 00:03:21,780 --> 00:03:24,150 This in the first index. 43 00:03:24,270 --> 00:03:28,260 So now our element is added here. 44 00:03:29,010 --> 00:03:29,310 Of. 45 00:03:31,740 --> 00:03:34,830 Our element is added here. 46 00:03:36,970 --> 00:03:37,300 Actually. 47 00:03:37,300 --> 00:03:44,890 Instead, we use the blue for the newly added elements and we we didn't touch. 48 00:03:45,430 --> 00:03:46,360 The first element. 49 00:03:46,360 --> 00:03:47,860 So index zero. 50 00:03:49,210 --> 00:03:56,470 And here this index here in this case, Android Kotlin training is going to stay the same, Right? 51 00:03:56,470 --> 00:03:59,230 It will not move or trigger anything. 52 00:03:59,230 --> 00:04:02,830 So it will stay the same. 53 00:04:04,310 --> 00:04:06,440 It will stay the same. 54 00:04:09,130 --> 00:04:13,560 But here we added to this is the new value. 55 00:04:13,570 --> 00:04:16,390 But all of this here three. 56 00:04:18,030 --> 00:04:20,730 Three, four, five. 57 00:04:20,760 --> 00:04:26,700 So here, before insertion, this was two and this was three and this was four. 58 00:04:26,700 --> 00:04:31,350 And there was no computer forensics course in here. 59 00:04:31,350 --> 00:04:34,380 Let's now remove the elements from the list. 60 00:04:34,380 --> 00:04:40,680 So often you will want to remove an item or set a set a set of items from a list. 61 00:04:40,680 --> 00:04:46,080 So, for example, when a player shoots down an alien from the sky, you will most likely want to remove 62 00:04:46,080 --> 00:04:47,850 it from the list of active aliens. 63 00:04:47,850 --> 00:04:53,550 So when a user decides to cancel their account on a web application you created, you will want to remove 64 00:04:53,550 --> 00:05:00,000 that user from the list of active users so you can remove an item according to its position in the list 65 00:05:00,030 --> 00:05:01,560 according to its value. 66 00:05:01,590 --> 00:05:08,610 So if you know the position of the item you want to remove from a list, you can use the Del statement. 67 00:05:09,610 --> 00:05:11,440 So how are we going to do that? 68 00:05:11,440 --> 00:05:14,440 Is now we add it here. 69 00:05:15,910 --> 00:05:17,530 Let's actually leave it here. 70 00:05:18,490 --> 00:05:23,740 Let's actually delete it so the new programmers will not confuse anything with it. 71 00:05:23,740 --> 00:05:25,240 So this is our list, right? 72 00:05:25,390 --> 00:05:28,840 And instead of doing this, let's add to the end. 73 00:05:28,840 --> 00:05:30,400 One, two, three, four. 74 00:05:31,020 --> 00:05:34,410 So zero, one, two, three, four here. 75 00:05:34,410 --> 00:05:35,760 And let's run here. 76 00:05:35,760 --> 00:05:39,720 And as you can see here, it added at the end. 77 00:05:39,810 --> 00:05:41,670 As you can see here, that's it. 78 00:05:42,150 --> 00:05:43,560 So now. 79 00:05:44,370 --> 00:05:48,630 I will also comment that this this is. 80 00:05:50,750 --> 00:05:59,720 This code inserts item to list into, list into list. 81 00:06:00,200 --> 00:06:03,030 And here we will remove an item from it. 82 00:06:03,050 --> 00:06:08,540 So now I want to hear drive again something here which is. 83 00:06:08,840 --> 00:06:11,270 So this is. 84 00:06:12,200 --> 00:06:12,920 One. 85 00:06:16,570 --> 00:06:18,510 We're sorry. 86 00:06:21,610 --> 00:06:23,290 One, two. 87 00:06:28,710 --> 00:06:28,900 Right? 88 00:06:29,500 --> 00:06:30,120 Right. 89 00:06:30,520 --> 00:06:40,150 So here, according to this this element, the computer forensics course goes to here, MySQL goes to 90 00:06:40,150 --> 00:06:40,930 here. 91 00:06:41,460 --> 00:06:44,040 And this poster here. 92 00:06:44,070 --> 00:06:44,550 All right. 93 00:06:44,550 --> 00:06:47,280 Let's actually illustrate it so you will make. 94 00:06:48,120 --> 00:06:49,350 You will understand better. 95 00:06:51,190 --> 00:06:52,960 Yeah, that's it. 96 00:06:53,840 --> 00:06:58,560 So the index of these values are, as you remember, zero. 97 00:06:58,560 --> 00:06:58,820 Oops. 98 00:06:58,820 --> 00:06:59,530 Sorry. 99 00:07:00,540 --> 00:07:03,750 Index of these values are zero. 100 00:07:04,650 --> 00:07:06,510 One, two. 101 00:07:08,250 --> 00:07:10,110 Three and four. 102 00:07:10,230 --> 00:07:10,800 That's it. 103 00:07:11,430 --> 00:07:17,260 So now after that, we will remove that item from the list. 104 00:07:17,280 --> 00:07:20,070 In this case, let's remove the base python. 105 00:07:20,430 --> 00:07:25,440 Let's remove the ethical hacking with python into 20 hours, which is the index for. 106 00:07:25,650 --> 00:07:29,460 Let's actually make it tick on them here. 107 00:07:29,580 --> 00:07:31,200 So here. 108 00:07:32,330 --> 00:07:34,520 We will remove this now, Right? 109 00:07:36,500 --> 00:07:38,120 So Del here. 110 00:07:39,870 --> 00:07:42,900 Oxer the courses and you enter the ID here. 111 00:07:42,900 --> 00:07:44,370 In this you enter the. 112 00:07:45,580 --> 00:07:46,300 Position here. 113 00:07:46,300 --> 00:07:49,660 And in this case, it's two and that's it. 114 00:07:49,870 --> 00:07:54,430 Now, we will print the courses here. 115 00:07:54,430 --> 00:07:59,650 And as you can see here, we have Android coding training here. 116 00:07:59,770 --> 00:08:00,520 Check. 117 00:08:01,260 --> 00:08:02,730 Best python course in the world. 118 00:08:03,560 --> 00:08:04,070 Check. 119 00:08:05,700 --> 00:08:07,470 Designing database models with. 120 00:08:08,300 --> 00:08:10,370 MySQL check. 121 00:08:11,040 --> 00:08:12,990 And computer forensics course. 122 00:08:12,990 --> 00:08:20,700 And as you can see here, we do not have ethical hacking anymore. 123 00:08:20,700 --> 00:08:26,400 So according to this, now the tree has become. 124 00:08:27,470 --> 00:08:29,450 To index. 125 00:08:30,240 --> 00:08:40,530 Index has become index two and index four become index three, and we no longer have index four here. 126 00:08:40,530 --> 00:08:44,820 So this index gone and also it splitted here. 127 00:08:44,820 --> 00:08:52,020 So the design of MySQL here got goes here and computer forensics here goes here. 128 00:08:52,020 --> 00:08:58,020 And in this list we do not have the index four anymore, but we deleted. 129 00:08:58,050 --> 00:09:00,300 Ethical hacking from the index two. 130 00:09:00,450 --> 00:09:02,910 This is how the list works. 131 00:09:02,910 --> 00:09:10,020 So in this case let's actually try what will index four give us here? 132 00:09:16,020 --> 00:09:20,130 Or actually, yes, let's actually instead of this, let's print the value. 133 00:09:21,320 --> 00:09:21,650 So. 134 00:09:22,580 --> 00:09:24,050 Print the value. 135 00:09:25,790 --> 00:09:30,110 Oxer the courses and print the value for all four. 136 00:09:30,500 --> 00:09:32,480 And here, as you can see here. 137 00:09:32,510 --> 00:09:35,940 List index out of range. 138 00:09:35,960 --> 00:09:43,310 This is the reason that gave us because there is no anymore fourth index here. 139 00:09:43,580 --> 00:09:48,380 So actually, instead of this we here, let's actually undelete this. 140 00:09:49,520 --> 00:09:51,710 And yes, perfect. 141 00:09:55,030 --> 00:09:55,540 Perfect. 142 00:09:56,700 --> 00:09:57,270 That's it. 143 00:10:14,760 --> 00:10:18,900 Now let's remove the another item from the position here. 144 00:10:20,150 --> 00:10:23,600 And now let's remove Del Oxley courses. 145 00:10:23,630 --> 00:10:26,390 Let's actually remove the item zero. 146 00:10:27,410 --> 00:10:28,610 And now. 147 00:10:31,330 --> 00:10:33,340 Actually, we don't need that code anymore. 148 00:10:35,310 --> 00:10:36,410 And that's it. 149 00:10:36,420 --> 00:10:40,340 As you can see here, we have left with three items in the list. 150 00:10:40,350 --> 00:10:41,310 So. 151 00:10:44,250 --> 00:10:45,030 That's it.