I'm very new to all of this, here's the code.
f="/home/name/Desktop/text.txt" fil = open (f,"r") data = fil.read() i=int(data) fil.close() import os os.remove(f) i=i+1 inp=file(f,'w') inp.write(i) inp.close()
I'm pretty much trying to make the value in the text file increase by one each time the script is run. I realize that there must be much better ways to do it, but I'm just playing around :p.
It works the way it's supposed to until I add the third "pharagraph". But the problem isn't in the new code but in the old one.
This is the "output" I get from Idle when I run it:
Traceback (most recent call last): File "/home/name/Desktop/script.pyw", line 6, in <module> i=int(data) ValueError: invalid literal for int() with base 10: 'o\n'
But before I add the third part there is no problem with the first part. Why is this?