title: Python: zip all folders in directory
body: <p>If I know the path of the directory, how can I zip <strong>separately</strong> all the folders in it? I tried something, but since I don't fully understand how the os module works, there's not much I can do.</p>
  
  <pre><code>import os, zipfile
  
  directory_path = str(raw_input())
  for folder in os.listdir(directory_path):
      zip_file = zipfile.ZipFile(folder + '.zip', 'w')
      for root, dirs, files in os.walk(directory_path+'/'+folder):
          for file in files:
              zip_file.write(os.path.join(root, file),file)
      zip_file.close()
  </code></pre>
  
  <p>The problem is that it only zips one folder from the directory.</p>
  
  <p>Example:</p>
  
  <pre><code>Directory
   |
   +-- folder1
   |  |  
   |  \-- file 1.1
   |
   +-- folder2
   |  |  
   |  \-- file 2.1
   |    
   +-- folder3
   |  |  
   |  +-- file 3.1
   |  \-- file 3.2
  </code></pre>
  
  <p>What I want to get is folder1.zip (contains file 1.1), folder2.zip (contains file 2.1) and folder2.zip (contains file 3.1 and file 3.2</p>
  
  <p>Any help is appreciated.</p>