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 'uniquewords'.
#Use a for loop to read the uniquewords 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 uniqurewords occured in the original text.
def main:
# Set up empty dictionary
counter
# Get input text
inputname inputEnter the path to the input file:
# Read the text and store each word in a set variable named uniquewords
with openinputname, as inputfile:
lines inputfile.read
words lines.split
# Add each unique word to dictionary with a counter of
uniquewords setwords
# Add each unique word to dictionary with a counter of
YOUR CODE HERE
# Count uniqueword occurances in original file
with openinputname, as inputfile:
lines inputfile.read
words lines.split
# Add one for each occurance of a uniqueword
YOUR CODE HERE
# Display the results
YOUR CODE HERE
#Call the main function
main
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
