Programming Examples
Python program to display only last line of a text file
Write a program to display only last line of a text file
Solutionfname=input("Enter the file name : ")
fp=open(fname,"r")
data=fp.readlines()
print("Last Line : ",data[-1])
fp.close()
OutputEnter the file name : myfile.txt
Last Line :Â ccc
