I want to delete all the lines in a file smart.txt and then add some strings of my own. smart.txt contains alot of lines.
I tried
import sys
import os
output=[]
f= open(smart.txt, 'r')
for line in f:
output.append(line)
if '*** P R O P E R T I E S ***' in line: break
f=open(smart.txt, 'w')
[f.write(data) for data in output]
f.write('*** Inclusions ***\n ')
f.write('*** Permanent ***\n ')
f.close()
I am getting an error
f= open(smart.txt, 'r')
NameError: name 'smart' is not defined
cannot figure out because smart.txt is present in the same directory.
Any suggestions?