I am a bit lost with this concept, and we have no examples to show us how to replace or search within a file.
The prompt:
Write a File
You will be provided a file path for input I, a file path for output O, a string S, and a string T.
Read the contents of I, replacing each occurrence of S with T and write the resulting information to file O.
You should replace O if it already exists.
The inputs are unknown, this is the only code we are provided with:
import sys
I= sys.argv[1]
O= sys.argv[2]
S= sys.argv[3]
T= sys.argv[4]
The only examples we have been provided are how to read a file, and how to write a simple text element into a file.
My code so far:
file1 = open(I, 'r')
data = file1.read()
I am truly stuck.