We are going to use counter.txt again for this. Make sure you already have some text in that file to see the difference.
Notice how this time it will add text to the end of a file. Each time you run it, it will add more text.
Exercise 1
Combine your skills with reading and appending to make a file that will read the existing counter.txt, count it up and then add another 10 numbers.
The first time it is run, it would read the final number of 1,2,3,4,5,6,7,8,9,10 and then it would append 11,12,13,14,15,16,17,18,29,20 and then if it is run again it would read 20 and move to 21,22,23,24,25,26,27,28,29,30 and so on.
Exercise 1
Combine your skills with reading and appending to make a file that will read the existing counter.txt, count it up and then add another 10 numbers.
The first time it is run, it would read the final number of 1,2,3,4,5,6,7,8,9,10 and then it would append 11,12,13,14,15,16,17,18,29,20 and then if it is run again it would read 20 and move to 21,22,23,24,25,26,27,28,29,30 and so on.
counter.txt (before append) | counter.txt 1st run | counter.txt |
1 |
1 |
1 |