Computer Science
Write a program that copies one file to another. Have the program read the file names from user ?
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)
Related Questions
Write a function AMCount() in Python, which should read each character of a text file STORY.TXT, should count and display the occurrence of alphabets A and M (including small cases a and m too).
Example :
If the file content is as follows :
Updated information
As simplified by official websites.The EUCount() function should display the output as :
A or a : 4
M or m : 2Write a program to count the number of upper-case alphabets present in a text file "Article.txt".
Write a program that appends the contents of one file to another. Have the program take the filenames from the 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'.