How do I remove a sentence from a file? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

How do I remove a sentence from a file?

I started learning python.can someone put me through. How do I remove "can someone put me through ".

5th May 2020, 4:46 AM
danielle daniel
danielle daniel - avatar
9 Answers
+ 2
As I know there is no way to do this by functions or methods But you can save the file as string then find the index and length of word you want to delete then make a substring of that string then clean the file then return the string to file
5th May 2020, 4:51 AM
ycsvenom
ycsvenom - avatar
+ 2
You can store content of file in string Then type string.replace("the thing you want to delete", '') Then format the file and put string into it
5th May 2020, 5:34 AM
ycsvenom
ycsvenom - avatar
+ 1
Tnx VENOM please can you illustrate with an example.
5th May 2020, 4:55 AM
danielle daniel
danielle daniel - avatar
0
I think there is a better idea I will explain it
5th May 2020, 5:26 AM
ycsvenom
ycsvenom - avatar
0
Tnx
5th May 2020, 5:39 AM
danielle daniel
danielle daniel - avatar
0
You are welcome ☺️
5th May 2020, 5:43 AM
ycsvenom
ycsvenom - avatar
0
This is awesome ğ
5th May 2020, 1:35 PM
danielle daniel
danielle daniel - avatar
0
narayanaprasad this is awesome ,I just have problem with moving the snippet from left to right.
5th May 2020, 1:38 PM
danielle daniel
danielle daniel - avatar