This is my code and file data given bellow. I have file with the name of test. In which Iām trying find a num in first column. If that number is found in any line, I want to delete that row.
def deleteline():
n=5
outfile=open('test.txt','r+')
line = outfile.readline()
while line !='':
lines= line.rstrip('\n')
listline=lines.split(',')
num=int(listline[0])
if n==num:
print(listline[1])
outfile.write(lines)
else:
print("no")
line= outfile.readline()
outfile.close()