Python program to append contents to file using write() method.
Program Description: We will append the data to the file using write() method in python.
We will use the concepts of file handling in python to append the contents to the file using write() method.
- The write() method is used to write some text to the file.
- For appending the contents to the end, we will open the file using 'a' mode.
Steps to append contents of file:
- Step 1: Open the file in append mode using 'a'.
- Step 2: Get the input data from the user and store it.
- Step 3: write the contents to the file using write() method.
Program to illustrate the solution of the problem
Output:
In the above code, we have opened the file for writing using 'a' mode. After this we have taken input from the user. And using the write() method, we have appended the data to the file.
need an explanation for this answer? contact us directly to get an explanation for this answer