<html><body><div style="color:#000; background-color:#fff; font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:12pt"><div>Need assistance with a questions in regards to python:</div><div><span class="Apple-tab-span" style="white-space:pre">   </span>1.<span style="font-family: 'Times New Roman'; font-size: medium;"> </span><span style="font-family: 'Times New Roman'; font-size: 16px;">function occurs(name, word) which looks for a word in the file with name name.</span></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: 'Times New Roman'; background-color: transparent; font-style: normal;"><span style="font-family: 'Times New Roman'; font-size: 16px;"><span class="Apple-tab-span" style="white-space:pre">   </span>2. </span>for each occurrence of the word we want to display its context by showing the 5 words (or so) preceding and following the occurrence, e.g. '... a man to set the river
 on fire. He had ...' for the first occurrence of 'river' in 'innocents.txt'.</div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: 'Times New Roman'; background-color: transparent; font-style: normal;"><span class="Apple-tab-span" style="white-space:pre">  </span>3. since the results may be long, we want to collect them all, and write them to a file whose name should be 'occurs'+name.</div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: 'Times New Roman'; background-color: transparent; font-style: normal;"><br></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: 'Times New Roman'; background-color: transparent; font-style: normal;"><em style="font-size: medium;">Hint</em><span style="font-size: 16px;">: at first ignore writing the results to a file. Simply collect all material in a string which you print to the screen. Then writing it to a file will be simple. To get both the word and its context you need an
 indexed loop through the words. Use the stripw() function we saw on individual words to make finding hits more accurate (e.g. the program found 'river.' above). Finally, the join() method will come in handy to reconstruct the context as a string.</span><br></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: 'Times New Roman'; background-color: transparent; font-style: normal;"><span style="font-size: 16px;"><br></span></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: 'Times New Roman'; background-color: transparent; font-style: normal;"><span style="font-size: 16px;">Link to final product: </span><a href="http://imgur.com/q1aAAhp" style="font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 12pt;">http://imgur.com/q1aAAhp</a></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: 'Times New Roman'; background-color: transparent; font-style:
 normal;"><span style="font-size: 16px;"><br></span></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: 'Times New Roman'; background-color: transparent; font-style: normal;"><span style="font-size: 16px;">For my program this is what i have so far, I am kinda lost at this point if you can please guide me to help resolve this program.</span></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: 'Times New Roman'; background-color: transparent; font-style: normal;"><span style="font-size: 16px;"><br></span></div><div style="background-color: transparent;"><span style="font-family: 'Times New Roman';">def lines(name, word):</span></div><div style="background-color: transparent;"><span style="font-family: 'Times New Roman';">    'print all lines of name in which word occurs'</span></div><div style="background-color: transparent;"><span style="font-family: 'Times New Roman';"><br></span></div><div
 style="background-color: transparent;"><span style="font-family: 'Times New Roman';">    infile = open(name, 'r')</span></div><div style="background-color: transparent;"><span style="font-family: 'Times New Roman';">    lst = infile.readlines()</span></div><div style="background-color: transparent;"><span style="font-family: 'Times New Roman';">    infile.close()</span></div><div style="background-color: transparent;"><span style="font-family: 'Times New Roman';"><br></span></div><div style="background-color: transparent;"><span style="font-family: 'Times New Roman';">    for i in range(len(lst)):</span></div><div style="background-color: transparent;"><span style="font-family: 'Times New Roman';">        line = lst[i]</span></div><div style="background-color: transparent;"><span style="font-family: 'Times New Roman';">        if wordin(word, line):</span></div><div
 style="background-color: transparent;"><span style="font-family: 'Times New Roman';">            w = ('Word found in line {}:'.format(i))</span></div><div style="background-color: transparent;"><span style="font-family: 'Times New Roman';">            #x = (lst[i+1])</span></div><div style="background-color: transparent;"><span style="font-family: 'Times New Roman';">            y = lst[i]</span><span style="font-family: 'Times New Roman'; background-color: transparent; font-size: 12pt;">        </span></div><div style="background-color: transparent;"><span style="font-family: 'Times New Roman';">             </span></div><div style="background-color: transparent;"><span style="font-family: 'Times New Roman';"></span></div><div style="background-color: transparent;"><span style="font-family: 'Times New
 Roman';">            print (''.join(y))</span></div></div></body></html>