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)

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now