(This assignment could be done as a modification of the program in Programming Challenge 2.) Write a program char asks rhe user for rhe name of a file. The program should display the contents of the file on the screen. Each line of screen output should be preceded with a line number, followed by a colon. The line numbering should start at "I

Respuesta :

Answer:

Python

file=open("file_name",r) #Opening the file we are using

f1=file.readlines() #Read each line of the file and save it into f1 vector

for x in range(len(f1)): #walk through every line in vector f1 and print it  

print(x+1, ".",f1[x]) """x+1 because the index begin in 0 so we add 1, ":" colon, f1[x] to take the x line"""