title: How to zip only specific type of files in a directory with Python?
body: <pre><code>    files = [os.listdir]
      files_to_zip = []
      for file in files:
          if str(file).__contains__(&quot;png&quot;):
              files_to_zip.append(file)
      shutil.make_archive(&quot;test&quot;, 'zip', files_to_zip)
  </code></pre>
  <p>My code is as above. I know it shouldn't work but I really want to understand the logic behind. I want to make a zip archive of the all *.png files in the current directory and then remove them all. Right now I can make a zip file containing all the files in the directory but I only want the png files. Thanks in advance.</p>