how to remove the last line of a text file with pytho code example
Example: remove last line of text file python
fd=open("file.txt","r")
d=fd.read()
fd.close()
m=d.split("\n")
s="\n".join(m[:-1])
fd=open("file.txt","w+")
for i in range(len(s)):
fd.write(s[i])
fd.close()