Q. Write a method in Python to read lines from a text file MYNOTES.TXT and display those lines which start with the alphabet 'K'.
Answer :
def display () :
file = open ('MYNOTES.TXT', 'r')
line = file.readline()
while line :
if line [ 0 ] == 'K' :
print (line)
line = file.readline ()
file.close()
display()
Let MYNOTES.TXT contains :
This is PathWalla So, Here you will get Solutions Korea is a good country This is due to Korean people are very good.
So, Our Output :
Korea is a good country
Korean people are very good.
Korean people are very good.
>>>
is there any output and mynotes txt text..?
ReplyDeleteOk, I have updated it.
DeletePost a Comment
You can help us by Clicking on ads. ^_^
Please do not send spam comment : )