Simple File Operation Program in Python

This is a simple python program to

  • Read content from a text file
  • Print the content
  • Write the content to another text file
inf=open('text11.txt','r')
outf=open('text22.txt','w')
line=inf.readline()
c=0
emptystr=''
while (line!=emptystr):
     outf.write(line)
     line=inf.readline()
     c=c+1
print('the number of lines in the text11file is ',c)
print('text11.txt File CONTENT')
print('               ')
inf.close()
outf.close() 
outf=open('text22.txt','r')
line1=outf.readline()
while(line1!=emptystr):
     print(line1,end='')
     line1=outf.readline()
outf.close()        
         

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.