Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please help me with this python assignment. Description: Write a program that prompts the user for a filename. Open the file, and read it one

Please help me with this python assignment.

Description:

Write a program that prompts the user for a filename. Open the file, and read it one line at a time. For each line split the line into a list of words called line_list. For each word in the current line_list, look to see if it is in a list called script_list (a list that is initially empty). If the word is not in script_list, add it to the script_list. Sort the script_list alphabetically.

Within the same program define a function called freq_count(). This function accepts a str and a list of words as arguments. It traverses the list of words and searches each word and counts the occurrences of the substring str within each word. Print each word along with the number of substring occurrences found within the associated word. Please note that you are not counting the number of occurrences in the file!

Modify your program so that it accepts the filename and the substring str as input from the user. After reading the file to build and sort the script_list, pass the script_list into the freq_count() function. Test your program with the romeo.txt file found in http://www.py4inf.com/code/

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beginning ASP.NET 4.5 Databases

Authors: Sandeep Chanda, Damien Foggon

3rd Edition

1430243805, 978-1430243809

More Books

Students also viewed these Databases questions

Question

Write Hund's rule?

Answered: 1 week ago