Answer:
Step-by-step explanation:
iname=input("Enter the file name: ")
inputfile=open(iname,'r')
lines=[]
for line in inputfile:
lines.append(line)
inputfile.close()
print("The file has ",len(lines)," lines")
while True:
linenumber=int(input("Enter the line number or 0 to quit: "))
if linenumber==0:
break
elif linenumber > len(lines):
print("Error: line number must be less than ", len(lines))
else:
print(linenumber, " : ", lines[linenumber - 1])