1
00:00:01,230 --> 00:00:08,910
In this video, we will add a complete feature to our program, complete meaning allowing the user to

2
00:00:08,910 --> 00:00:13,050
mark a to do item as complete as done.

3
00:00:13,050 --> 00:00:17,880
So then that item will be deleted from the list of to dos.

4
00:00:18,600 --> 00:00:24,630
For this, we're going to be using a case complete statement.

5
00:00:26,280 --> 00:00:34,620
So if the user enters add show edit complete in case of complete, what do we want to do here?

6
00:00:35,190 --> 00:00:37,110
So this is the logic here.

7
00:00:37,830 --> 00:00:46,260
When you want to manipulate something in this case, we want to manipulate the list.

8
00:00:46,620 --> 00:00:51,600
So if the user enters complete, we want to modify the list.

9
00:00:51,600 --> 00:00:55,150
So we want to remove one item from that list.

10
00:00:55,170 --> 00:00:58,470
That is a manipulation process.

11
00:00:59,260 --> 00:01:02,770
And when we think about manipulation, we think about methods.

12
00:01:03,640 --> 00:01:12,910
So if I was you to find out how to remove an item from a list, I would open a python console and use

13
00:01:12,910 --> 00:01:15,790
the function and enter the list there.

14
00:01:16,810 --> 00:01:19,330
That will give me a list of methods.

15
00:01:19,570 --> 00:01:21,320
So I'll take a look here.

16
00:01:21,340 --> 00:01:25,420
Perhaps I find something like remove.

17
00:01:26,080 --> 00:01:32,550
Yo, here is a remove so I might then ask help for lists.

18
00:01:32,560 --> 00:01:34,990
Remove to see how remove works.

19
00:01:36,520 --> 00:01:43,360
So this gets a value as argument and it removes the first occurrence of value.

20
00:01:43,360 --> 00:01:44,590
Value is that.

21
00:01:46,090 --> 00:01:47,710
So then I'll try this.

22
00:01:47,710 --> 00:01:50,170
Maybe my list is equal to.

23
00:01:51,690 --> 00:01:55,440
A, B, and C.

24
00:01:55,740 --> 00:02:01,080
So my lists, you know, the notation of methods that remove.

25
00:02:03,650 --> 00:02:04,880
And that the value.

26
00:02:04,910 --> 00:02:09,169
Well, this means by value they mean the item.

27
00:02:09,169 --> 00:02:12,560
So maybe be and then try my list.

28
00:02:14,030 --> 00:02:18,140
And B is gone from my list.

29
00:02:19,710 --> 00:02:22,920
So that is one way to find out what methods you need.

30
00:02:23,790 --> 00:02:26,250
Another way, of course, is to use Google.

31
00:02:28,130 --> 00:02:35,480
So if you did a search on Google, a simple search such as methods to remove items from Python lists,

32
00:02:35,510 --> 00:02:37,550
you would get some answers.

33
00:02:37,580 --> 00:02:41,640
For example, here it says Clear pop remove.

34
00:02:41,660 --> 00:02:44,920
So it seems there are other methods as well.

35
00:02:44,930 --> 00:02:46,490
So Google search.

36
00:02:46,790 --> 00:02:51,050
Some Internet research might give you more answers to your questions.

37
00:02:51,920 --> 00:02:53,590
So clear and pop.

38
00:02:53,840 --> 00:02:57,110
You can also find these in.

39
00:02:58,900 --> 00:02:59,560
Dear.

40
00:03:01,120 --> 00:03:02,260
So you see?

41
00:03:02,260 --> 00:03:03,850
Clear should be here.

42
00:03:05,600 --> 00:03:10,850
Here is clear and pop as well, so you might want to try this out.

43
00:03:10,880 --> 00:03:12,590
Help list.

44
00:03:12,590 --> 00:03:13,580
That's clear.

45
00:03:14,300 --> 00:03:15,560
Remove all items.

46
00:03:15,560 --> 00:03:17,870
So perhaps that is not what you need.

47
00:03:17,870 --> 00:03:20,750
But anyway, this is how you learn.

48
00:03:20,960 --> 00:03:22,790
So you experiment with things.

49
00:03:22,790 --> 00:03:23,870
You research.

50
00:03:24,530 --> 00:03:26,990
Try out, list that pop.

51
00:03:28,930 --> 00:03:35,830
So in case of pop, this removes and returns item at index.

52
00:03:36,040 --> 00:03:40,080
So in the case of pop, the argument is an index.

53
00:03:40,090 --> 00:03:42,850
It is not the item itself.

54
00:03:42,940 --> 00:03:47,950
So that means you could use pop as in my list that pop.

55
00:03:49,510 --> 00:03:55,090
And if you say one here, C is removed and it is also returned.

56
00:03:55,210 --> 00:04:00,910
So you see this method returned the removed item.

57
00:04:00,910 --> 00:04:04,660
And if you check my list now, it only has a.

58
00:04:05,400 --> 00:04:09,590
Now, perhaps you might be wondering what is minus one?

59
00:04:09,610 --> 00:04:13,600
Well, this is a default value of the argument.

60
00:04:14,110 --> 00:04:16,029
Meaning if you.

61
00:04:18,290 --> 00:04:29,450
Half again, my list is equal to A, B and C, and you simply say my list that Pope, without any arguments,

62
00:04:29,450 --> 00:04:33,830
that means minus one will be the default argument.

63
00:04:35,350 --> 00:04:39,190
Minus one corresponds with the last item.

64
00:04:39,190 --> 00:04:49,660
So less indexes has another system besides the default system, which means zero index for a an index

65
00:04:49,660 --> 00:04:57,520
of one for B and an index of two for C, You can also specify indexes like minus one for C, minus two

66
00:04:57,520 --> 00:05:01,660
for B, minus three for A, and so on.

67
00:05:03,630 --> 00:05:06,660
So my list, you get that?

68
00:05:07,550 --> 00:05:10,640
So we have two options to remove or pop.

69
00:05:10,910 --> 00:05:15,770
Let's see which is the one we need so complete.

70
00:05:15,770 --> 00:05:20,240
And then we say if the user enters complete, then we want to ask the user.

71
00:05:21,220 --> 00:05:23,710
Perhaps this same question here.

72
00:05:23,950 --> 00:05:33,300
So indented with tab a number is equal to and input number of the two due to edit.

73
00:05:33,310 --> 00:05:35,320
Well, let's change this to complete.

74
00:05:35,320 --> 00:05:44,560
So we prompt the user with an input function and we convert that the user inputs to an integer.

75
00:05:45,190 --> 00:05:48,430
So the user will enter one, two or three or four.

76
00:05:48,850 --> 00:05:54,760
And so we have the index of the item we want to remove to complete.

77
00:05:54,760 --> 00:05:59,830
Then what we do is we point to two dos dot pop.

78
00:06:00,960 --> 00:06:01,800
Number.

79
00:06:03,060 --> 00:06:06,720
So that's the thing we did here as well.

80
00:06:07,800 --> 00:06:11,640
We remove the item with that particular index.

81
00:06:12,030 --> 00:06:14,310
So let's see how this goes.

82
00:06:15,240 --> 00:06:16,640
Type add, show or edit.

83
00:06:16,650 --> 00:06:17,730
Let's add some items.

84
00:06:17,730 --> 00:06:19,980
Clean add.

85
00:06:21,670 --> 00:06:25,360
Through show zero four.

86
00:06:25,360 --> 00:06:28,120
Clean one four through.

87
00:06:29,260 --> 00:06:31,990
So let's place one presenter.

88
00:06:32,920 --> 00:06:35,110
And let's show now the items.

89
00:06:37,110 --> 00:06:44,070
Oh, that didn't work because I entered one when I was asked to enter, add, show, edit or exit.

90
00:06:44,070 --> 00:06:49,380
So I should enter complete here first and then one so complete.

91
00:06:49,380 --> 00:06:52,200
Then we get asked number of the two due to complete.

92
00:06:52,830 --> 00:06:53,580
Let's say one.

93
00:06:53,580 --> 00:06:54,090
No.

94
00:06:54,660 --> 00:07:02,200
And then we say show so clean is remained and through is removed.

95
00:07:03,060 --> 00:07:10,140
Now something quick we might want to improve here is to start the list from one and not zero.

96
00:07:11,700 --> 00:07:16,850
So for that, we need to go to the show case.

97
00:07:17,220 --> 00:07:24,630
So from index item in enumerate, we say that index and here we say plus one.

98
00:07:26,970 --> 00:07:31,710
So if we do that rerun, we say add.

99
00:07:33,790 --> 00:07:35,710
Fleeing at.

100
00:07:37,080 --> 00:07:39,060
Do and then show.

101
00:07:39,090 --> 00:07:42,810
Now this will start from one, two and so on.

102
00:07:43,530 --> 00:07:49,500
And then in edit, we subtract one so we compensate for.

103
00:07:50,350 --> 00:07:53,580
That's increase and we should do the same in here.

104
00:07:53,590 --> 00:07:56,680
So number minus one.

105
00:07:57,760 --> 00:07:59,980
So that should be okay now.

106
00:07:59,980 --> 00:08:06,940
So let's try again at do at, clean at.

107
00:08:09,270 --> 00:08:11,520
Paste and.

108
00:08:12,440 --> 00:08:13,130
Show.

109
00:08:14,180 --> 00:08:15,530
One, two, three.

110
00:08:16,190 --> 00:08:20,540
We want to complete item with index.

111
00:08:21,930 --> 00:08:24,690
To so show.

112
00:08:26,480 --> 00:08:26,810
Yeah.

113
00:08:26,810 --> 00:08:29,740
So clean was the item within the zoo.

114
00:08:29,750 --> 00:08:35,240
So we removed that item and now we have to do and paste only.

115
00:08:36,559 --> 00:08:45,620
Another improvement is we want to add edit complete here or exit so that it shows in here.

116
00:08:46,550 --> 00:08:47,960
Yeah, let's check that quickly.

117
00:08:48,680 --> 00:08:49,070
Yeah.

118
00:08:49,100 --> 00:08:49,760
Here we go.

119
00:08:49,790 --> 00:08:52,070
Complete this part of the query now.

120
00:08:56,870 --> 00:08:59,660
And so this completes this video.

121
00:08:59,690 --> 00:09:02,320
That was the complete feature that we added.

122
00:09:02,330 --> 00:09:08,270
Let's keep on improving the app while learning new Python core features.

123
00:09:08,660 --> 00:09:09,980
I'll talk to you in the next video.

124
00:09:10,280 --> 00:09:10,820
Thank you.

