HomeFile Handling Write a method in python to read the content from a text file diary.txt line by line and display the same on screen. 3 Comments Facebook Twitter Q. Write a method in python to read the content from a text file diary.txt line by line and display the same on screen. Answer = file = open("diary.txt", "r") print (file.read())
no, it has said to read line-by-line.
ReplyDeleteso correct will be:
file = open("diary.txt", "r")
for line in file:
print(line)
Have you tried in your PC, because answer is wrong.
DeleteThis program is wrong as it says to rwad line by line it shuold be
ReplyDeletefile=open("diary.txt", "r")
while str:
str=file.readline()
print(str,end= ' ')
file.close()
Post a Comment
You can help us by Clicking on ads. ^_^
Please do not send spam comment : )