Welcome to the fourth and final challenge of section 19.
I'm in the section 19 workspace in the challenge_4 project.
We also have a challenge_4_solution project
which contains a solution.
This challenge is pretty easy, but it's kind of fun.
The idea is that we have the Romeo and Juliet play that we've used before.
And what we want to do is we want to read that in,
add line numbers to it and then write it out to a new file.
So we're not going to modify the original file. We're going to create a copy of the
original file that has line numbers on it.
Okay. So it's real nice, really easy to do, and we'll get you a little bit
of experience writing more files.
Let me run this for you.
I'm going to run the solution, and it shows no output, it just says copy complete
because there's not much to show. But let's open up the
enclosing folder here so we can see what's created.
Now here you can see the original Romeo and Juliet.
There's no line numbers here on the left.
And this is the file that's created right here, RomeoandJuliet_out. You can name that anything you like.
And you can see that that has line numbers now nice and formatted.
And you can see them all lined up right around the side.
There are a lot of line numbers in this file,
about 5000 something. I believe
now there's one thing I don't like about this solution
is -- let me scroll there, you see this solution
gives line numbers to all these empty lines.
I guess that's okay.It all depends on what you want a line number. So
I'm doing it two ways. I'm doing it like this.
And then I'll show you another way in a second, which
gives only line numbers to lines that actually have text.
Okay. So let me run that solution in a second I'll show that one to you.
Okay. So I'm going to run this other version.
And its copy is complete, and then we'll take a look at what it looks like.
And right here, RomeoandJuliet_out.
And you can see it looks exactly like the previous one except that blank lines aren't numbered.
So you can see that we're skipping those blank lines, we're still displaying
them like they were in the original file, but we're not numbering them.
And I think it looks a little easier to read this way. I mean I don't know whether
line numbers are put into scripts like this or not,but
different option. It gives you two different solutions, and you can experiment with that.
I'll show you both solutions when we do the solution project in a little bit.
So that's it. Have fun.
Okay. So that's it for this video. I'll see you in the solution.