I am trying to write the following loop to a .txt file (in addition to printing the output to terminal). On doing so I get an error that says:
> TypeError:function takes exactly 1 argument (2 given)
I understand what the error is trying to convey, but is there a way to work around this. I do need the labels and the results output to the .txt file just like they are printed on the terminal
Here is the code I am using:
out_write = open(write_to, 'wb')
for arr in top_k:
print(labels[arr], results[arr])
out_write.write(labels[arr], results[arr])
print ("\n\n\n")
out_write("\n\n\n")
out_write.close()
I am working in python 2.7
out_write.write('{} {}'.format(labels[arr], results[arr]))%,.format(), f-strings) or use two calls to.write()