1
00:00:00,550 --> 00:00:06,790
Hey, previously we implemented the ADD case, adding to the items in a text file.

2
00:00:06,790 --> 00:00:09,780
In this video we will implement the show case.

3
00:00:09,790 --> 00:00:16,300
This is something you can also do on your own, I believe, because it will be the same code basically

4
00:00:16,480 --> 00:00:18,220
that we wrote previously.

5
00:00:19,410 --> 00:00:20,970
With a difference That's here.

6
00:00:20,970 --> 00:00:24,180
All we have to do is read operations.

7
00:00:28,110 --> 00:00:31,020
So let's see how we approach this problem.

8
00:00:31,770 --> 00:00:35,940
What we have so far is we iterate over the to do list.

9
00:00:37,320 --> 00:00:44,400
However, this will not currently work because if I run this problem and I, I say immediately show

10
00:00:44,700 --> 00:00:46,050
we're going to get an error.

11
00:00:47,840 --> 00:00:50,000
So in line 19.

12
00:00:50,000 --> 00:00:52,730
And here it says that.

13
00:00:53,660 --> 00:00:54,600
Name error.

14
00:00:54,620 --> 00:00:57,350
Name to dos is no difference.

15
00:00:57,650 --> 00:01:07,700
So what happened is we run the program and the program asks us for input, show edits, complete or

16
00:01:07,700 --> 00:01:10,070
exit or ad.

17
00:01:10,070 --> 00:01:11,720
And so we enter the show.

18
00:01:11,960 --> 00:01:14,390
Then the program checked.

19
00:01:15,140 --> 00:01:17,780
Try to match the show string.

20
00:01:18,350 --> 00:01:21,380
So this is not matched here because this is ads.

21
00:01:21,410 --> 00:01:25,850
Therefore, this code was never executed.

22
00:01:27,200 --> 00:01:31,190
So the interpreter wants to the next case show.

23
00:01:32,860 --> 00:01:35,380
Show was the inputs we enter.

24
00:01:35,380 --> 00:01:43,720
Therefore we get this code executed and there is no variable declaration for to dos here.

25
00:01:44,920 --> 00:01:48,550
Therefore we got this name error to do is not defined.

26
00:01:49,330 --> 00:01:54,390
Therefore we need to define to those in here to do is equal to what?

27
00:01:54,400 --> 00:01:57,760
Well first creates a file is equal to open.

28
00:02:00,520 --> 00:02:02,830
To do the text.

29
00:02:02,830 --> 00:02:08,979
RT The path to the file that has existing to dos in read mode.

30
00:02:10,970 --> 00:02:14,000
That to do is equal to file that red lines.

31
00:02:16,760 --> 00:02:17,570
And that's it.

32
00:02:17,600 --> 00:02:19,140
Don't forget to close the file.

33
00:02:19,160 --> 00:02:20,330
File that close.

34
00:02:20,420 --> 00:02:21,830
So once we get.

35
00:02:23,170 --> 00:02:24,840
The items in the list.

36
00:02:24,850 --> 00:02:28,720
You can close the file because the items are now in that variable.

37
00:02:28,720 --> 00:02:35,050
So if you close the file, that will not affect the content that is already in that variable.

38
00:02:35,770 --> 00:02:42,310
So make it break line perhaps here and try out the code show.

39
00:02:43,760 --> 00:02:45,350
And here we go.

40
00:02:45,950 --> 00:02:48,230
Those are the items.

41
00:02:49,130 --> 00:02:59,110
We do see some break lines between these items because what happens is that the file has brake lines.

42
00:02:59,120 --> 00:02:59,630
Right?

43
00:03:00,380 --> 00:03:01,730
There is a backslash.

44
00:03:01,730 --> 00:03:06,370
And here there is another backslash N in here, in here as well, and so on.

45
00:03:06,380 --> 00:03:07,820
So brake lines.

46
00:03:09,660 --> 00:03:10,590
And.

47
00:03:11,700 --> 00:03:20,810
This loop here, the print function will actually create brake lines for itself.

48
00:03:20,820 --> 00:03:23,130
So we end up with two brake lines.

49
00:03:23,130 --> 00:03:27,150
That's why we have this extra brake line in here.

50
00:03:28,820 --> 00:03:32,330
So what we need to do here is we need to.

51
00:03:33,340 --> 00:03:36,940
Edit the to do lists.

52
00:03:37,240 --> 00:03:44,590
We need to go to each of the items and remove a backslash and character from that.

53
00:03:45,010 --> 00:03:47,950
We can use list comprehension to do this.

54
00:03:48,190 --> 00:03:51,370
But this is something we will do in the next video tutorial.

55
00:03:51,370 --> 00:03:57,010
So for this lecture this was enough information and I'll talk to you in the next one.

56
00:03:57,040 --> 00:03:57,250
So you.

