How can i remove specific lines from a file | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

How can i remove specific lines from a file

28th Sep 2021, 11:28 AM
Abdulmagid Algodimy
5 Answers
+ 2
with open(<file>) as my_file: lines = my_file.readlines() lines.pop(<whatever line num>) with open(<file>, 'w') as update: update.writelines(lines)
28th Sep 2021, 12:01 PM
Slick
Slick - avatar
+ 1
It does, cause I've done it. You haven't posted your own code once....
28th Sep 2021, 2:57 PM
Slick
Slick - avatar
0
Thanks i will try this
28th Sep 2021, 12:03 PM
Abdulmagid Algodimy
0
Unfortunately it didn't work
28th Sep 2021, 2:56 PM
Abdulmagid Algodimy
0
Well ,I think i will try it again .. thank you anyway
28th Sep 2021, 3:00 PM
Abdulmagid Algodimy