Question: The following function open_filel) opens a file called 'exampletxt and returns the file pointer. This function is called within main and the file pointer is

The following function open_filel) opens a file called 'exampletxt and returns the file pointer. This function is called within main and the file pointer is used to read lines in the file. Create a dictionary called dict of_words that have words as keys' and [integar) counters as values. The counter values keep a count of the number of times a word has appeared in the text file. In the end, store the dictionary keyvalues in a list, sort and print the list on the screen. Note that the counts are not case-sensitive, that is, Word is the same as word or wORd Also, note that your progrom should account for if a, (comma) separates two words, e.g. tood, water, electricity Example: Contents of input text file I do not think there is any thrill that can go through the human heart like that felt by the inventor as he sees some creation of the brain unfolding to success such emotions make a man forget food sleep friends love everything Nikola Tesla Output (unfolding. 11 Code Full Screen code.py New 1- def open file): fpointer open ( example.txt') turn fpointer 4 ef main): dictlist [] fp open file() to iterate for key, value in dict of words.items (): 10 temp (key,value) dictlist.append (temp) print (sorted(dictlist)) 13 14 main
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
