title: recursive search of file with specific extension
body: <p>I am trying to get count of all the file which ends with particular extension (which user will pass) with the path. We have sub folders as well so search has to be recursive.
  Below is what i am trying but it is throwing error. Please suggest where is the gap.
  If i remove <code>if file.endswith(extension):</code> line then it gives count of all files (which includes files with all extension)</p>
  
  <pre><code>import os, sys
  
  def fileCount(path, extension):
      count = 0
      for root, dirs, file in os.walk(path):
          if file.endswith(extension):
              count += len(file)
      return count
  
  print fileCount('/home/export/JobDefinition', '.car')
  </code></pre>
  
  <p>Below is the output:</p>
  
  <pre><code>$ python test.py
  Traceback (most recent call last):
    File "test.py", line 11, in &lt;module&gt;
      print fileCount('/home/export/JobDefinition', '.car')
    File "test.py", line 6, in fileCount
      if file.endswith(extension):
  AttributeError: 'list' object has no attribute 'endswith'
  </code></pre>