Simple as the title, really. But struggling somehow.
delete lines with boop
beep
boop
bop
Hey
beep
boop
bop
file_path = "C:\\downloads\\test.txt"
with open(file_path, "r") as f:
lines = f.readlines()
with open(file_path, "w") as f:
for line in lines:
if line.rfind("boop") >= 0:
f.write(line)
file_in.close()
I'm not understanding the best way to delete or clear the line completely.