Using a python program and changing it I made a .txt file displaying the story 'Robin Hood' replace any instance where 'Robin' or 'Robin Hood' is present for 'Shrek'.

To start off, I went online and downloaded a .txt file for Robin Hood and opened up the following program.

This program finds a file called 'RobinHood.txt', the name of the file I want to change.
Once the program finds this I use the 'find' and 'replace' keywords to replace any instance of 'Robin Hood' and 'Robin' with 'Shrek' and to then take this edited file and make it into a new copy called 'Shrek.txt' and leave it there.

The following, more complex program does the same thing but allows you to manually decide on files and text replacements during runtime, the result is the same.

Comments