This post has NOT been accepted by the mailing list yet.
So I'm doing a problem on the Alice_in_wonderland.txt where I have to write a program that reads a piece of text from a file specified by the user, counts the number of occurrences of each word, and writes a sorted list of words and their counts to an output file. The list of words should be sorted based on the counts, so that the most popular words appear at the top. Words with the same counts should be sorted alphabetically.
for words in full_text_words:
stripped_words = words.strip(".,!?'`\"- ();:")
word_count[stripped_words] += 1
word_count[stripped_words] = 1
ordered_keys = word_count.keys()
print ("All the words and their frequency in", 'alice in wonderland')
for k in ordered_keys:
print (k, word_count[k])
The Output here is just all of the words in the document NOT SORTED by amount of occurrence.
I need help sorting this output of words in the Alice_in_wonderland.txt, as well as help asking the user for the input information about the files.
If anyone could give me some guidance you will really be helping me out.