Read all words from a given text file and print a count for each
Clash Royale CLAN TAG #URR8PPP Read all words from a given text file and print a count for each Test.txt contains the following sentence(How much wood would a woodchuck chuck if a woodchuck could chuck wood.) This program is supposed to read all words from a given text file (until eof) and print out a count for each word. The word should be processed case-insensitive (all capitals), punctuation should be removed and the output should be sorted by frequency. However I've come to a simple problem where it's counting lines and not the words, help a brother out. Make a translation table for getting rid of non-word characters dropChars = "!@#$%ˆ& ()_+-={}|\:;"’<>,.?/1234567890" dropDict = dict([(c, '') for c in dropChars]) dropTable = str.maketrans(dropDict) Read a file and build the table. f = open("Test.txt") testList=list() lineNum = 0 table = {} # dictionary: words -> set of line numbers for line in f: testList.append(line) for ...