Having two file names entered from users, the task is to append the content of the second file to the content of the first file.
Input : file1.txt file2.txt Ouput : Content of first file (before appending) - geeksfor Content of second file (before appending) - geeks Content of first file (after appending) - geeksforgeeks Content of second file (after appending) - geeks
- Enter the names of the files.
- Open both the files in read only mode using the
- Print the contents of the files before appending using the
- Close both the files using the
- Open the first file in append mode and the second file in read mode.
- Append the contents of the second file to the first file using the
- Reposition the cursor of the files at the beginning using the
- Print the contents of the appended files.
- Close both the files.
Suppose the text files
file2.txt contain the following data.
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.