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 textStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started