Question: Write a Python program to read a filename lines.py and displays the contents of the file with line number. For example, if the file contains:

Write a Python program to read a filename lines.py and displays the contents of the file with line number. For example, if the file contains:

''' This is line 1 This is line 2 This is line 3 '''

Then the program output is:

1: ''' 2: This is line 1 3: This is line 2 4: This is line 3 5: '''

Note, the lines.py file is provided. Use the lines.py input file. The output looks exactly like the input file contents except for the added line number and colon. Follow the example output.

Hint: Watch out for the blank line.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!