4:12 bartleby.com = bartleby Q&A Engineering / Computer Engineering / Q&A Library / *Code i... *Code in python Write a program that allo... *Code in python Write a program that allows the user to...


4:12<br>bartleby.com<br>= bartleby<br>Q&A<br>Engineering / Computer Engineering / Q&A Library / *Code i...<br>*Code in python Write a program that allo...<br>*Code in python<br>Write a program that allows the user to navigate the<br>lines of text in a file. The program should prompt<br>the user for a filename and input the lines of text<br>into a list. The program then enters a loop in which<br>it prints the number of lines in the file and prompts<br>the user for a line number. Actual line numbers<br>range from 1 to the number of lines in the file. If the<br>input is 0, the program quits. Otherwise, the<br>program prints the line associated with that<br>number.<br>An example file and the program input and output<br>is shown below:<br>example.txt<br>Line 1.<br>Line 2.<br>Line 3.<br>Enter the input file name: example.txt The file has 3<br>lines. Enter a line number [0 to quit]: 22: Line 2.<br>The file has 3 lines. Enter a line number [0 to quit]: 4<br>ERROR: line number must be less than 3. The file<br>has 3 lines. Enter a line number [0 to quit]: 0<br>Make sure the program gracefully handles a user<br>entering a line number that is too high.<br>-><br>2<br>

Extracted text: 4:12 bartleby.com = bartleby Q&A Engineering / Computer Engineering / Q&A Library / *Code i... *Code in python Write a program that allo... *Code in python Write a program that allows the user to navigate the lines of text in a file. The program should prompt the user for a filename and input 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. Otherwise, the program prints the line associated with that number. An example file and the program input and output is shown below: example.txt Line 1. Line 2. Line 3. Enter the input file name: example.txt The file has 3 lines. Enter a line number [0 to quit]: 22: Line 2. The file has 3 lines. Enter a line number [0 to quit]: 4 ERROR: line number must be less than 3. The file has 3 lines. Enter a line number [0 to quit]: 0 Make sure the program gracefully handles a user entering a line number that is too high. -> 2

Jun 09, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here