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, convert the word to lowercase and 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 that comes as a text file resource with our textbook.
Note: With step 2, you are printing each word, not just words with non-zero occurrences of the substring str. As examples of what the substring search results would be, given the word "there" and a substring str of th, the result would be 1, and the print result for that one word would be there 1; given the same word there and a substring str of e, the result would be 2, and the print result for that one word would be there 2; and finally, given the same word there and a substring str of z, the result would be 0, and the print result for that one word would be there 0.