Question: Write a program that allows the user to navigate through the lines of text in a file. The program prompts the user for a filename

Write a program that allows the user to navigate through the lines of text in a file.
The program prompts the user for a filename and inputs the lines of text into a list.
The program then enters a loop in which it prints the number of lines in the file and prompts the user for a line number.
Actual line numbers range from 1 to the number of lines in the file.
If the input is 0, the program quits.If the input is greater than the lines in the file, prompt the user that the input must be less than or equal to the number of lines in the file.
The program prints the line in the file associated with the input number.
To test your program run the navigate.py file.
Your program's output should look like the following:
Enter the input file name: data.md The file has 3 lines. Enter a line number [0 to quit]: 11 : Lambert 3410.50 The file has 3 lines. Enter a line number [0 to quit]: 22 : Osborne 226.25 The file has 3 lines. Enter a line number [0 to quit]: 33 : Giacometti 5100.70 The file has 3 lines. Enter a line number [0 to quit]: 0
Task #01: Program properly navigates the provided files

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 Programming Questions!