So,I have this problem,the code below will delete the 3rd line in a text file.
with open("sample.txt","r") as f:
    lines = f.readlines()
    del lines[2] 
    with open("sample.txt", "w+") as f2:
        for line in lines:
            f2.write(line)
How to delete all lines from a text file?
 
     
    