Question: Write a Python program that allows the user to navigate the lines of text in a file. The program should prompt the user for a

Write a Python program that allows the user to navigate the lines of text in a file. The program should prompt the user for a filename. The program should use a function, loadData, to accomplish the following: Load the file content into a dictionary, fileContent, which will contain each line and its corresponding line number. The function should also populate a second dictionary, fileInfo, with each word in the file and the number of times each word appears in the file. Once the loadData function completes, the program will print the contents of fileInfo dictionary; each word and its count appearing on a separate line. 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 (text) associated with that line number. Note: If the value entered is greater than the number of lines in the file or the value is negative, the program prints a message (e.g. invalid line number) and prompts the user to enter a line number Note: The loadData function take one argument, the name of the file.

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!