To write a python program for copying the contents from one file to another file.
PC Anaconda - Python 3.7
Get the file name and location form the user
Give a new name to create the copy of the content
Read the file and close the file
Now write the content in the new file
when done print "File copied successfully
End the program
#Developed by: Priyadharshini Raja
#Register number: 23013809
def copy(fname,newfile):
with open(fname,'r')as fp:
with open(newfile,'w')as fp1:
data=fp.read()
fp1.write(data)
fname=input("Enter an existing file:")
newfile=input("Enter a name for new file:")
copy(fname,newfile)
Thus the program is written to copy the contents from one file to another file.