[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

program that search string in text file and do something

alon.najman at gmail.com wrote:

> Hi, I'm new to thing forum and to this programming in python!
> can someone help me and write me how to write a program that do:
> - search for a string in certain text file and if it founds the string it
> delete the file? and print something?

Programming is mostly about splitting a complex task into baby steps.

Do you know how to open a file?
Do you know how to iterate over the lines of that file?
Do you know how to search for a string in that line (i. e. another string)?
Do you know how to delete a file?

Work through a Python tutorial or the first chapters of beginner's textbook, 
then try your hand at each of the subtasks outlined above. Consult the 
documentation for missing parts. 

Once you have some code we will help you improve or even fix it.

What we won't do is write a program for you ready to present to your