I\'m trying to read a text from a text file, read lines, delete lines that contain specific string (in this case \'bad\' and \'naughty\'). The code I wrote goes like this:>
You could simply not include the line into the new file instead of doing replace.
for line in infile : if 'bad' not in line and 'naughty' not in line: newopen.write(line)