Question: Python question. I'm stuck with this one, my output should like the left side (6 Jellicle 5 Cats 2 And) without 1 they 1 moon.
Python question. I'm stuck with this one, my output should like the left side (6 Jellicle 5 Cats 2 And) without 1 they 1 moon.


Problem program.pynovel.txt fname ' novel . txt' fptr open fname) x fptr.read () wordsx.split() data -th for word in words: The aim in this question is to find the main characters in a novel by doing textual analysis. We will hypothesise that the most frequent capitalised words in a novel are likely to be the character names. You should write a program to open a file called novel.txt and read in all the words. For this purpose let's assume that words are groups of letters and punctuation separated by spaces. if word[0].isupper ) if word in data: data [word]data [word] 1 Your program should then count the number of times each word appears and print out the top 3 words which start with a capital letter. For example, for our first sample file which you can download here: else: data[word] 1 for word indata: print (data [word],word) Jellicle Cats are black and white, Jellicle Cats are rather small; Jellicle Cats are merry and bright, And pleasant to hear when they caterwaul. Jellicle Cats have cheerful faces, Jellicle Cats have bright black eyes; They like to practise their airs and graces And wait for the Jellicle Moon to rise. Submissions
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
