-4
f=open("arquivo.txt", 'w')
I’m making a code to plot a Gaussian on the random walker (Statistical Mechanic) and is giving this error when saving in the file my "Count". That is the code:
for j in range (0,t):
count=0
for i in range (0,100):
x[i]=randint(0,1)
if x[i]==1:
count=count+1
f.write=('0.1f\n'%(count))
f.close()
That is the mistake:
File "estat", line 23, in <module>
f.write=('0.1f\n'%(count))
TypeError: not all arguments converted during string formatting
What can it be?
Please post the entire code for further verification.
– Nathan Schroeder
Python is not my area, but you have tried to convert its variable
count
for string? The problem may be this, try sof.write=('0.1f\n'%(str(count)))
– Matheus Ribeiro