Programming Pandit

c/c++/c#/Javav/Python


Latest Update

Monday, November 23, 2020

Python program to read a text file line by line and display each word separated by a # by G Krishna Chauhan

Source Code

 

file=open("demo.txt","r")

doc=file.readlines()

for i in doc:

   words=i.split()

   for a in words:

       print(a+"#")

file.close()

OUTPUT

This is python programming and PHP programming.


This#

is#

python#

programming#

and#

PHP#

programming.#


No comments:

Post a Comment