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.txt
Kennedy.txt
King.txt
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
Get step-by-step solutions from verified subject matter experts
