Trevor_G
0
Q:

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()
1

New to Communities?

Join the community