Task

Replace every occurring instance of a piece of text in a group of text files with another one.



For this task we want to replace the text   "Goodbye London!"   with   "Hello New York!"   for a list of files.




L(fname) fs:list_dir(‘.’)
   I fname.ends_with(‘.txt’)
      V fcontents = File(fname).read()
      File(fname, ‘w’).write(fcontents.replace(‘Goodbye London!’, ‘Hello, New York!’))
 