Python program to copy contents of one file to another file using file Handling.
Problem Description: We need to copy all data from one file to another file. The names of both files are provided by the user as input. If the destination file is not present create a new one.
We will use the concepts of file handling in python and read and write the contents in the file.
Steps to copy contents from one file to another
- Step 1: Take users the name of source and destination files.
- Step 2: If the source there is a source file then copy the contents of source file to the destination file.
- Step 3: If the destination file doesn't exist, create a new one.
Program to illustrate the solution of the problem
Output:
Here, we have asked users for inputs of file name for the source and destination. After the user has provided valid name of source file, we have copied its contents to the destination file.
need an explanation for this answer? contact us directly to get an explanation for this answer