I am new to Python and I am trying to concatenate the rows of one file1.txt with another file2.txt and its output must be to another file3.txt For example:
file1.txt:
Hello how are u?:
NYC:
Coffee Shop:
File2.txt:
Jhon
WDC
Starbucks
The output should be:
file3.txt:
Hello how are u?: Jhon
NYC: WDC
Coffe Shop: Starbucks
I have this:
from io import open
input1=open("file1.txt","r",encoding="utf-8")
input2=open("file2.txt","r",encoding="utf-8")
output=open("file3.txt","w",encoding="utf-8")
file1=input1.readlines()
file2=input2.readlines()
j=0
for i in ingles:
out=file1[j]+":"+file2[j]
j=j+1
output.writelines(out)
input1.close()
input2.close()
output.close()
It create the file but it does not concatenate the result in the same row...
for i in ingles
supposed to be doing? – dbmitch