I want to write a program that gives some integer value. I have a file with a value in the first line. How can I change the value of line (for example to 12). This is my code, but this gets a value and I want to go to line 2 and addition m to that number in line 2 but it doesn't work.
t=open('pash.txt', 'r')
g=[]
for i in range(3):
g.append(t.readline())
t.close()
g[o-1]=(int(g[o-1]))+m # o is the number of line in file
print(g[o-1])
t=open("pash.txt","w")
for i in range(3):
t.write(str(g[i]))
t.write('\n')
t.close()