read write - Take lines from two files, output into same line- python -
read write - Take lines from two files, output into same line- python - i pretty new python , attempting open 2 files take first line in first file, write out file, take first line in sec file , append same line in output file, separated tab. i've attempted code this, , outfile ends beingness whole contents of first file, followed entire contents of sec file. included print statements because wanted see going on in terminal while script running, why there. ideas? import sys infilename = sys.argv[1] infile = open(infilename, 'r') infilename2 = sys.argv[2] infile2 = open(infilename2, 'r') outfilename = "combined_data.txt" outfile = open(outfilename, 'a') line in infile: outfile.write(str(line) + '\t') print line line2 in infile2: outfile.write(str(line2) + '\n') print line infile.close() infile2.close() outfile.close() thank you! you can utilize zip this: with open(fi...