title: How get number of subfolders and folders using Python os walks?
body: <p>What I have a directory of folders and subfolders. What I'm trying to do is get the number of subfolders within the folders, and plot them on a scatter plot using matplotlib. I have the code to get the number of files, but how would I get the number of subfolders within a folder. This probably has a simple answer but I'm a newb to Python. Any help is appreciated.</p>
  
  <p>This is the code I have so far to get the number of files:</p>
  
  <pre><code>import os
  import matplotlib.pyplot as plt
  
  def fcount(path):
      count1 = 0
      for f in os.listdir(path):
          if os.path.isfile(os.path.join(path, f)):
              count1 += 1
  
      return count1
  
  path = "/Desktop/lay"
  print fcount(path)
  </code></pre>