I have a text file that already prepends until it has 10 lines
Line 10 Line 9 Line 8 Line 7 Line 6 Line 5 Line 4 Line 3 Line 2 Line 1
Now if I prepend more line into this text file. It'll become 11 Line
Line 11 Line 10 Line 9 Line 8 Line 7 Line 6 Line 5 Line 4 Line 3 Line 2 Line 1
And now, I want to remove the Line 1 from the file to keep it only 10 lines long. How do I do that in python?
Once you have read your lines, you can use slicing before writing them again with:
lines = lines[:10] # Keep 10 first lines
1.4m articles
1.4m replys
5 comments
57.0k users