Q. Write code to print just the last line of a text file 'data.txt'.
Answer =
fin = open ("data.txt", "r") lineList = fin.readlines () fin.close() print ("Last line = " , lineList [-1],) print ("Total lines = ", len (lineList))
Answer =
fin = open ("data.txt", "r") lineList = fin.readlines () fin.close() print ("Last line = " , lineList [-1],) print ("Total lines = ", len (lineList))
Post a Comment
You can help us by Clicking on ads. ^_^
Please do not send spam comment : )