00:01
Okay, so let's try this.
00:02
The question says a file name numbers .txte contains an unknown number of lines, each consisting of a single integer.
00:10
Write some code that computes the sum of all the integers.
00:15
Okay, so i've actually gone and created a file that has this format, just so that we can actually work with it here.
00:27
So we're going to open the file, and we're going to say f contents equals.
00:33
F.
00:34
Read.
00:34
And we're going to do f .com close to close the file.
00:39
So let's see.
00:42
What does it want us to do? we want to write a code that computes the sum of all these integers and stores the sum in a variable named sum.
00:52
Okay, so we have our f contents, right? and since these integers are all on different lines, they're separated by a backslash n.
01:02
And so if we want to split this up into different integers, we can say f and let's say, let's call this split file is equal to f contents.
01:20
Split.
01:22
They want it to split at backslash n, at backslash n.
01:28
And so then we have this variable called split file, which is split up this numbers.
01:35
Dot text into individual lines.
01:40
And it also gave us one at the end just because we've included this backslash and at the end...