def deletematerial():
print('Deleting of material ')
fh_r = open("AQUESTO.txt", "r")
name = input('Enter the name of de material to eliminate: ').lower()
print("\n")
with open("bb.txt", "w") as output:
for line in fh_r:
if name not in line.strip("\n"):
output.write(line)
fh_r.close()
os.remove("AQUESTO.txt")
os.replace('bb.txt', 'AQUESTO.txt')
The text file looks like this:
example:
name | priority
====================
gun | low
--------------------
granade | high
--------------------
explosive| high
--------------------
Everytime I delete something the file finish like this:
name | priority
====================
gun | low
-------------------- <-------this line of separation, I don't want
-------------------- I only want one of those two, without
explosive| high deleting the others
--------------------
So I want to replace those two lines of characters for one