Write a function file_copy that takes two string parameters (in_file and out_file) and copies the content of in_file into out_file. Assume that in_file exists before file_copy is called. For example, the following would be correct input and output:

Respuesta :

def file_copy(in_file, out_file):

   f = open(in_file, "r")

   fi = open(out_file, "w")

   content = f.readlines()

   txt = ""

   for i in content:

       txt += i

   fi.write(txt)

your_file = "FileName.txt"

file_copy(your_file, "CopyOfFileName.txt")

I did this in python 3. I hope this helps!

fichoh

The program is a function which copies from a preexisting file to another file. The function is written in python 3 and it goes thus :

def file_copy(in_file, out_file):

#initialize a function named file_cppy which takes in two parameters

f1 = open(in_file, "r")

#open file in read mode and assign to the variable f1

f2 = open(out_file, "w")

#create and open another file in write mode, assign to the variable f2

file_content = f.readlines()

#read the entire content into a list

text = ""

for line in content:

#iterate through the content in the list

text +=line

#add each line to the empty text variable

f2.write(text)

#write each text to the newly created file.

Learn more : https://brainly.com/question/13594876