append file in python

Description

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

Solution

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

Explanation

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



Interesting Pattern Programs: for more Patterns

Input:
5
Output:
*
**
***
****
*****
****
***
**
*Solution
Input:
5
Output:
    *
   ***
  *****
 *******
*********
 *******
  *****
   ***
    *Solution
Input:
5
Output:
*        *
**      **
***    ***
****  ****
**********Solution
Input:
5
Output:
*       *
**     **
***   ***
**** ****
*********Solution
Input:
5
Output:
*       *
**     **
***   ***
**** ****
*********
**** ****
***   ***
**     **
*       *Solution
Input:
5
Output:
*********
 *******
  *****
   ***
    *
   ***
  *****
 *******
*********Solution

Related Programs