title: Python; reading file and finding desired text
body: <p>Need to create a function with two params, a filename to open and a pattern.</p>
  
  <p>The pattern will be a search string.</p>
  
  <p>Eg. the function will open sentence.txt that has something like "The quick brown fox" (can possibly be more than one line)</p>
  
  <p>The pattern will be "brown fox"</p>
  
  <p>So if found, as this will be, it should return a line number and index of the character the found string starts on. Else, return -1.</p>
  
  <p>Catch is I've never programmed in python before so I don't know the syntax.
  Previously coded in C, C#, Java, VB, etc..</p>
  
  <p>EDIT:</p>
  
  <h1>.....Id</h1>
  
  <h1>.....Name</h1>
  
  #
  
  <h1>my intent was for you to write HW3 code as iteration or</h1>
  
  <h1>nested iterations that explicitly index the character</h1>
  
  <h1>string as an array; i.e, the Python index() also known as</h1>
  
  <h1>string.index() function is not allowed for this homework.</h1>
  
  #
  
  <p>filename = raw_input('Enter filename: ')</p>
  
  <p>pattern = raw_input('Enter pattern: ')</p>
  
  <p>def findPattern(fname, pat):</p>
  
  <h1>Reading in one whole chunk</h1>
  
  <pre><code>filetext = open(fname).read()
  if pat in filetext:
      print("Found it -- chunk")
  else:
      print("Nothing -- chunk")
  </code></pre>
  
  <h1>Reading in line by line</h1>
  
  <pre><code>for search in open(fname):
      if pat in search:
          print("Found it -- line")
      else:
          print("Nothing -- line")    
  </code></pre>
  
  <p>findPattern(filename, pattern)</p>