Hello my question is simple, I have a loop that write results on a file and it takes time to go through the whole loop, is there a way I can make python write every result it gets, or do I have to close the file inside the loop ? will it be longer ? thank you guys
fi= open('results','a')
for j in range(1,100):
tt=j
res=scipy.optimize.newton(zero,15)
fi.write("\n"+str(tt)+", " + str(res)+", "+str( zero(res) ) )
print("done")
print("--- %s seconds ---" % (time.time() - start_time))
winsound.Beep(300,2000)
fi.closed