Question: Using Python. Please Explain. Thanks 2. (Looking for Words, 10pt) You're trying to remember some memorable quote from a memorable book you read, but you
Using Python. Please Explain. Thanks

2. (Looking for Words, 10pt) You're trying to remember some memorable quote from a memorable book you read, but you can't. All you can remember is that it contained a specific word. Write a function extend(word, fname) which looks through the text in fname, and when it finds word, shows the word together with the five words that follow it (to give context). Below are some testruns with innocents.txt. Python 3.5.2 Shell File Edit Shell Debug Options Window Help >>>extend ('pageants', 'innocents.txt') More: pageants as before who lay a More: pageants the most extraordinary spectacles that More: pageants were exhibited here in presence More: pageants and processions every thing one More: pageants and its fishing holydays We More: pageants of an age that has >>>extend ('punishments', 'innocents.txt') More: punishments at school and how we Ln: 342 Col: 4 Hint: We've seen two ways to go from the text to a list of words. Using .split() or using the re.split() method Either one is fine (I used re.split for the testruns above). The disadvantage of split) is that you won't find all occurrences of a word, since punctuation remains after the split; the disadvantage of re.split() is that after using it all punctuation is gone, so when you're joining words back together, you've lost punctuation. We are ok with this
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
