title: How to display line count where regex match was found
body: <p>I've seen several examples of how to display a line count, and have tried to implement those into my code, but was unsuccessful. I am a Python newbie, so I guess I have more to learn. Can someone show me how I would display the line count of the match found in a file, thanks?</p>
  
  <pre><code>elif searchType =='3':
        print "Directory to be searched: c:\SQA_log "
        print " "
        directory = os.path.join("c:\\","SQA_log")
  
        regex = re.compile(r'(?:3\d){6}')
        for root,dirname, files in os.walk(directory):
           for file in files:
             if file.endswith(".log") or file.endswith(".txt"):
                f=open(os.path.join(root,file))
                for line in f.readlines():
                    searchedstr = regex.findall(line)
                    for word in searchedstr:
                       print "String found: " + word
                       print "File: " + os.path.join(root,file)
                       break
                       f.close()
  </code></pre>