Question: PYTHON CODE Write a program which takes any text file and displays top n number of words in descending order of occurrences ( case insensitive

PYTHON CODE

Write a program which takes any text file and displays top n number of words in descending order of occurrences (case insensitive) in the file.

I've tried it and came up with about 10 lines of code (without including empty lines , just one command per line) to complete. Even with that, I think there is some room to improve.

Sample text files: Lincoln.txtPYTHON CODE Write a program which takes any text file and displays Kennedy.txttop n number of words in descending order of occurrences (case insensitive) King.txtin the file. I've tried it and came up with about 10

Expected output are shown below. NOTE: Don't sweat if the number of frequencies are off a little bit. I did not do rigorous validation on effective words checkup.

Enter file: Kennedy.txt the : 31 of : 24 to : 16 we : 16 and : 13 a : 12 our : 10 that : 8 not : 7 in : 7

Transcribed image text

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!