Write Python Program to Read the Contents of a File


Topic: Write Python Program to Read the Contents of a File

Solution

a=str(input("Enter the name of the file with .txt extension:"))
file2=open(a,'r')
line=file2.readline()
while(line!=""):
    print(line)
    line=file2.readline()
file2.close()	



List all Python Programs