We will open a file in the 'w' mode and then truncate it. Then we accept three lines of input from the user, and append them to the file.
Extra Credit:
In the next example, we comment most of the lines of the solution and also reuse the prompt by using replacement characters.
We need not have called
truncate
on the fp, since opening a file in 'w' mode automatically truncates it.
Can you please do the study drill 3 of this exercise ?
ReplyDeletetarget.write (line1 + "\n" + line2 + "\n" + line3)
Delete