226k views
4 votes
A file named "games.txt" exists and has 80 lines of data. You open the file with the following line of code.

aFile = open("games.txt", "w")

You write two lines to the file in the program. How many lines are in the file when you close your file?

70

0

73

3

User Phileas
by
5.9k points

1 Answer

2 votes

Answer:

2 lines

Step-by-step explanation:

The "w" flag will overwrite any content, so the existing 80 lines are lost.

Then, if you write two lines, there are two lines in the file.

You could argue that the final newline character causes a third line to be present, but logically, there are two lines.

User Mike Laren
by
6.7k points