I have a code, which takes a string from input_file_1
and two numbers to slice the string from input_file_2
, the output strings are written in output_file
and divided by space:
def task_3(input_file_1, input_file_2, output_file):
with open(input_file_1) as i_f_1, open(input_file_2) as i_f_2, open(output_file, 'w') as o_f:
result = []
for line_1, line_2 in zip(i_f_1.readlines(), i_f_2.readlines()):
start, finish = line_2.split()
result.append(line_1[int(start):int(finish)+1])
o_f.write(' '.join(repr(i) for i in result))
task_3('test_import_file_2_1.txt', 'test_import_file_2_2.txt', 'output_file.txt')
The problem is that output looks like this:
'tPGRIXNp' 'JEflNBYRbuLkOiZqQHYNNTWPUIPNibcIpSL' 'yDvBXxyOUwjGAemSbsuHupMmGIWpTwv'...
Whereas it must look like this:
tPGRIXNp JEflNBYRbuLkOiZqQHYNNTWPUIPNibcIpSL yDvBXxyOUwjGAemSbsuHupMmGIWpTwv...
As you can see strings are attached to single quotes, which I can't get rid off.