Trying to make a function that copies the content of one file and writes it to another
<p>I have a question that states
<strong>Write a function fcopy() that takes as input two file names (as strings) and copies the content of the first file into the second.</strong>
and I want to know how to go about solving this.</p>

<p>My first file is named example, and the second file is named output, both text files are in .txt format, and the path to them are 
<em>"C:\Users\HOME\Desktop\Introduction to Computing\Lab\assignments\example.txt"</em>
and <em>"C:\Users\HOME\Desktop\Introduction to Computing\Lab\assignments\output.txt"</em></p>

<p>If you really need to, you could write a simple wrapper function to accomplish this:</p>

<pre><code>def copy_file(orig_file_name, copy_file_name):
    with open(orig_file_name, 'r') as orig_file, open(copy_file_name, 'w+') as cpy_file:
        orig_file = orig_file.read()
        cpy_file.write(orig_file)
</code></pre>

<p>But as @Frogboxe has already said, the correct way to copy a file is to used the shutil library:</p>

<pre><code>import shutil
shutil.copy(target_file, copy_file)
</code></pre>

python python-3.x