I have a trivial problem
I want the words that were removed to all be uploaded to the same file where I'm making a mistake: D
infile = "tada.txt"
outfile = "tada.txt"
word = "vul"
tada=(''.join(word))
delete_list = tada
with open(infile) as fin, open(outfile, "w+") as fout:
for line in fin:
for word in delete_list:
line = line.replace(word, "")
fout.write(line)
from text
this is vul great
if there is a word vul in the file
output is
this is great
so I want the same output to be in the same file
but the problem is that the script deletes everything and the file remains empty