I just want to write the data from File_1.txt, File_2.txt and File_3.txt into Final.txt. Below is the code which I have written:
with open("Final.txt",'a+') as _:
try:
with open("File_1.txt") as f1, open("File_2.txt") as f2, open("File_3.txt") as f3:
_.writelines([f1.read(), f2.read(), f3.read()])
_.write('\n')
except Exception:
pass
Suppose if File_1.txt, File_2.txt or File_3.txt is missing, I just want to write from the remaining available files.
Example: Suppose File_1.txt is missing, remaining files data (File_2.txt and File_3.txt) should be written in Final.txt.