Computer Science
Write a program that appends the contents of one file to another. Have the program take the filenames from the user.
Python File Handling
4 Likes
Answer
def append_file(f1, f2):
with open(f1, 'r') as source:
with open(f2, 'a') 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: ")
append_file(source_file, destination_file)
Answered By
3 Likes
Related Questions
Write a program to count the number of upper-case alphabets present in a text file "Article.txt".
Write a program that copies one file to another. Have the program read the file names from user ?
Write a method in python to read lines from a text file MYNOTES.TXT, and display those lines, which are starting with an alphabet 'K'.
Write a method/function DISPLAYWORDS() in python to read lines from a text file STORY.TXT, and display those words, which are less than 4 characters.