Hey, previously we implemented the ADD case, adding to the items in a text file.
In this video we will implement the show case.
This is something you can also do on your own, I believe, because it will be the same code basically
that we wrote previously.
With a difference That's here.
All we have to do is read operations.
So let's see how we approach this problem.
What we have so far is we iterate over the to do list.
However, this will not currently work because if I run this problem and I, I say immediately show
we're going to get an error.
So in line 19.
And here it says that.
Name error.
Name to dos is no difference.
So what happened is we run the program and the program asks us for input, show edits, complete or
exit or ad.
And so we enter the show.
Then the program checked.
Try to match the show string.
So this is not matched here because this is ads.
Therefore, this code was never executed.
So the interpreter wants to the next case show.
Show was the inputs we enter.
Therefore we get this code executed and there is no variable declaration for to dos here.
Therefore we got this name error to do is not defined.
Therefore we need to define to those in here to do is equal to what?
Well first creates a file is equal to open.
To do the text.
RT The path to the file that has existing to dos in read mode.
That to do is equal to file that red lines.
And that's it.
Don't forget to close the file.
File that close.
So once we get.
The items in the list.
You can close the file because the items are now in that variable.
So if you close the file, that will not affect the content that is already in that variable.
So make it break line perhaps here and try out the code show.
And here we go.
Those are the items.
We do see some break lines between these items because what happens is that the file has brake lines.
Right?
There is a backslash.
And here there is another backslash N in here, in here as well, and so on.
So brake lines.
And.
This loop here, the print function will actually create brake lines for itself.
So we end up with two brake lines.
That's why we have this extra brake line in here.
So what we need to do here is we need to.
Edit the to do lists.
We need to go to each of the items and remove a backslash and character from that.
We can use list comprehension to do this.
But this is something we will do in the next video tutorial.
So for this lecture this was enough information and I'll talk to you in the next one.
So you.