I am using a while loop like
while a>0:
a=a+1
a1=open("/python25/file1.txt","r+")
a2=str(a)
a3=a1.write(a2)
It is storing only the last value of a, but how can I store any row or all the rows in file?
SUBHABRATAIISC
0
Newbie Poster
Recommended Answers
Jump to PostTry this ...
# open a file for appending fap = open("file1.txt", "a") n = 0 # append numbers 1 to 9 to the file while n < 9: n = n + 1 # or n += 1 fap.write(str(n)) fap.close()
All 2 Replies
Reply to this topic
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.