The output of the following code is shown in the attached image:
print(reg_num)
print(final_df)
^^^Outputs of print(reg_num)andprint(final_df) as visible on terminal^^^
In the output image, 6 lines of outputs are visible. Pairs of 3 each. I want to save each pair into separate text files.
Expected output:
output1.txt
16SCSE102014
2
output2.txt
16SCSE101350
0
output3.txt
16SCSE101002
0
My attempt:
z = [reg_num, final_df]
print(z)
ctr = 0
for i in z:
ctr += 1
with open('d:\\output'+str(ctr)+'.txt', 'w') as f:
for j in range(len(z)):
f.write((str(z[j]) + "\n"))
but I couldn't bring the required data into the text files.
What is the solution?
for j in range(len(z)):tofor j in i: