title: Creating a list of files and separate the extension
body: <p>So, in the folder INFACT, I have the following files(and many more with the same extensions):</p>
  
  <pre><code>BFDRYCKSE.ad
  BFDRYCKSE.txt
  BFFALIV2SE.ad
  BFFALIV2SE.txt
  </code></pre>
  
  <p>I need to zip those files according to the filename, but only those mentioned above. My final result should be:</p>
  
  <pre><code>BFDRYCKSE.zip, contains(BFDRYCKSE.ad, BFDRYCKSE.txt)
  BFFALIV2SE.zip, contains(BFFALIV2SE.ad BFFALIV2SE.txt)
  </code></pre>
  
  <p>Here's my code:</p>
  
  <pre><code>import os
  import glob
  import zipfile
  setfile = r'C:\Users\vijo9001\Desktop\Infact'
  myset = [
          "BFBRODSE",
          "BFDRYCKSE",
          "BFFALIV2SE",
          "BFFALIVSSE",
          "BFFRYSTSE",
          "BFHUSHA1SE",
          "BFHUSHA2SE",
          "BFHUSHALSE",
          "BFKONFEKSE",
          "BFKROPPVSE",
          "BFKROPP2SE",
          "BFLIV2SE",
          "BFLIVSSE",
          "BFMAKEUPSE",
          "BFMEJERISE",
          "BFTOBAKSE"
      ]
  os.chdir(setfile)
  list_of_lists = []
  for i, pattern in enumerate(myset):
       list_of_files = glob.glob(r'*{pattern}*'.format(pattern=myset[i]))
       list_of_lists.append(list_of_files)
       n = 0
       file = os.path.splitext(list_of_files[0])[0]
       with zipfile.ZipFile(file + '.zip', 'w') as myzip:
            for f in list_of_files:
                 myzip.write(f, compress_type=zipfile.ZIP_DEFLATED)
  </code></pre>
  
  <p>I keep getting </p>
  
  <pre><code>Traceback (most recent call last):
    File "C:/Users/vijo9001/Desktop/Retailers Check/aaa.py", line 29, in &lt;module&gt;
      file = os.path.splitext(list_of_files[0])[0]
  IndexError: list index out of range
  </code></pre>
  
  <p>Why is that?</p>