append file in python

Python Program to write something new into file sample.txt without earsing the exisiting content.

Try your Solution

Strongly recommended to Solve it on your own, Don't directly go to the solution given below.

#write your code here

Program or Solution

				
			
					
file=open("sample1.txt",'a')
content=input("Ente Input String:")
file.write(content)
file.close()

			
				
			

Program Explanation

open the file in append mode write the content into the file using write() method close() the file.

Comments


Related Programs