Q:

Write python program to read a file and display its contents with line numbers on a screen

0

Write a program to read a file and display its contents with line numbers on a screen

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

import os

os.chdir("c:/ahmedfiles")
myfile=open("KSU.txt","r")
lineNumber=1
for line in myfile:
    print(lineNumber,".",line)
    lineNumber=lineNumber+1
myfile.close()

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Write python program to copy one file to another... >>
<< Write a python program to display contents of a fi...