-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQ73.py
More file actions
16 lines (14 loc) · 704 Bytes
/
Copy pathQ73.py
File metadata and controls
16 lines (14 loc) · 704 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
def copy_file(source_file, destination_file):
try:
with open(source_file, "r") as src:
content = src.read()
with open(destination_file, "w") as dest:
dest.write(content)
print(f"Contents of '{source_file}' have been copied to '{destination_file}'.")
except FileNotFoundError:
print(f"The source file '{source_file}' does not exist. Please provide a valid file.")
except Exception as e:
print(f"An error occurred: {e}")
source = input("Enter the source file name (including extension): ")
destination = input("Enter the destination file name (including extension): ")
copy_file(source, destination)