65.9k views
4 votes
Write a program that will open a file named thisFile.txt and write every other line into the file thatFile.txt. Assume the input file (thisFile.txt) resides in the same directory as your code file, and that your output file (thatFile.txt) will reside in the same location. Do not attempt to read from or write to other locations.

User Aremyst
by
4.2k points

1 Answer

2 votes

Answer:

Check the explanation

Step-by-step explanation:

The programmable code to solve the question above will be written in a python programming language (which is a high-level, interpreted, general-purpose programming language.)

f = open('thisFile.txt', 'r')

w = open('thatFile.txt', 'w')

count = 0

for line in f:

if count % 2 == 0:

w.write(line)

count += 1

w.close()

f.close()

User Moobie
by
4.6k points