I need to read from 3 txt files and merge them into one big txt file.
Ex text file1:
John
Mary
Joe
Ex text file2:
Alabama
Alaska
Michigan
Ex text file3:
Maybe
Attending
Not Attending
I'm not sure what else to add to my code
path = '/home/pi/Documents/Test/name.txt'
file1 = open (path, 'r')
name = file1.read()
statepath = '/home/pi/Documents/Test/state.txt'
file2 = open (path, 'r')
states = file2.read()
statuspath = '/home/pi/Documents/Test/status.txt'
file3 = open(statuspath, 'r')
status = file3.read()
finalpath = '/home/pi/Documents/Test/final.txt'
file4 = open(finalpath, 'w')
final = file4.read()
for item in name, states, status:
final.write(file1, "\n")
final.write(file2, "\n")
final.write(file3, "\n")
file1.close()
file2.close()
file3.close()
final.close()
final expected output of the file is
John <------- first value in file1
Alabama <------ first value in file2
Maybe <------- first value in file 3
Mary <---------- second value in file 1
Alaska
Attending
Joe
Michigan
Not Attending
Basically trying to loop through all of them and print them sequentially not sure how to loop.