Question: #Modify the program below to demonstrate the following: #Prompt the user to input the path to that file. #Read and store the text in a

#Modify the program below to demonstrate the following:
#Prompt the user to input the path to that file.
#Read and store the text in a set called 'unique_words'.
#Use a for loop to read the unique_words set and add them to a dictionary called 'counter'.
#Note that the dictionary has already been setup in the code below.
#Read original file and find out how many times each word (stored in uniqure_words) occured in the original text.
def main():
# Set up empty dictionary
counter ={}
# Get input text
input_name = input('Enter the path to the input file: ')
# Read the text and store each word in a set variable named unique_words
with open(input_name, 'r') as input_file:
lines = input_file.read()
words = lines.split()
# Add each unique word to dictionary with a counter of
unique_words = set(words)
# Add each unique word to dictionary with a counter of
'', YOUR CODE HERE ''
# Count unique_word occurances in original file
with open(input_name, 'r') as input_file:
lines = input_file.read()
words = lines.split()
# Add one for each occurance of a unique_word
''. YOUR CODE HERE ''
# Display the results
,', YOUR CODE HERE ''
#Call the main function
main()
 #Modify the program below to demonstrate the following: #Prompt the user

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!