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. code example

Example 1: 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.

# 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.

file1 = open(I, 'r')
Icontent = file1.read()
editedData = Icontent.replace(S, T)
file2 = open(O, 'w')
file2.write(editedData)
file1.close()
file2.close()

Example 2: You will be provided a file path for input I, a file path for output O, a string S, and a string T.

file1 = open(I, 'r')
Icontent = file1.read()
editedData = Icontent.replace(S, T)
file2 = open(O, 'w')
file2.write(editedData)
file1.close()
file2.close()