So right now I have a text file which is formatted like this:
ID1 - Reason for ban
ID2 - Reason for ban
ID3 - Reason for ban
I have a command that basically removes the user's ban and that should delete the users details in the text file.
ID2 = 12345 #sample ID
with open("yourfile.txt", "r") as f:
lines = f.readlines()
with open("yourfile.txt", "w") as f:
for line in lines:
ID, reason = line.split(" - ")
if ID == ID2:
f.write("\n")
The code above deletes everything regardless of if the ID matches or not, is there another solution that could detect if the ID in the textfile matches up with the users request?