### question 2 20 points import alic txt and cound the number of wordsand characters in 4944870

Question 2 (20 points): import
alic.txt and cound the number of wordsand characters in it. Count the number of words in the txt file and find the mostrepeated one. In your program, first convert all words to lower case and thenconvert the first character to the upper case. Then do theanalysis. We are not interested in the following words: The, A, And, To,It In [ ]: BanWords
=[‘The’, ‘A’,’And’, ‘To’,’It’] filename
= ‘alice.txt’text
= ‘?&#39;(filename)
# open the fileprint(‘Please Wait, Counting the number of words..’)counts
= ‘?’
# create an empty dictionary the file
for line ‘?’ text:
# keyword in the for loop line
= line.’?&#39;()
#convert to lower lettres. line
= line.’?&#39;()
#convert the first letter to capital lettre. words
= line.’?&#39;()
#spereate the words in the line based on whitespace
for word
in words: word
= word.rstrip(”’).,’s,’S,)”,)”,.,,,),:,’,””’) word
= word.lstrip(”&#39;(,”,(“,”(”’)
if word “?”
in BanWords:
# the missing keyword let the loop continue if the word is not in the BanWords list.
if word
in counts: counts[word]
= counts[word]
+1
else: counts[word]
= 1MaxRep
= 0MaxWord
=
for k,v
in counts.’?&#39;():
# we need both keys and values of the dictionary in the loop
if v
> MaxRep: MaxRep
= v MaxWord
= kprint (MaxWord,’ is the most repeted word with ‘,MaxRep,’times’) . . .