Class - 12 CBSE Computer Science Important File Handling Questions 2025
Write a program that copies one file to another. Have the program read the file names from user ?
Python File Handling
3 Likes
Answer
def copy_file(file1, file2):
with open(file1, 'r') as source:
with open(file2, 'w') as destination:
destination.write(source.read())
source_file = input("Enter the name of the source file: ")
destination_file = input("Enter the name of the destination file: ")
copy_file(source_file, destination_file)
Answered By
2 Likes