title: Get name of folders in zip files - Python
body: <p>I have been searching the whole stackoverflow to get an idea on how to extract only names of subfolders from a zip file path.</p>
  
  <p>I tried using tkinter to get the zip path:</p>
  
  <pre><code>Import os
  from tkinter import filedialog
  import tkinter as tk
  from zipfile import ZipFile
  
  root = tk.Tk()
  root.withdraw()
  root.filename = filedialog.askopenfilename(initialdir=os.getcwd(), title="Select file", filetypes=[("zip", "*.zip")])
  </code></pre>
  
  <p>And used the ZipFile and namelist to hopefully get the names of all subfolders.</p>
  
  <pre><code>with ZipFile(root.filename, 'r') as f:
      names = f.namelist()
  </code></pre>
  
  <p>However, I get that:</p>
  
  <pre><code>['CS10/', 'CS10/.DS_Store', '__MACOSX/', '__MACOSX/CS10/', '__MACOSX/CS10/._.DS_Store', etc........
  </code></pre>
  
  <p>I want to know if there is a way to just get the folder name which is in this case CS10 and so on.</p>
  
  <p>Example:
  If I have 3 folders named: "Apple" "Orange" "Pear" in a zip file path(Users/Kiona/fruits.zip)
  I want to print ['Apple','Orange','Pear']</p>
  
  <p>I am pretty new with Python so I hope this doesn't sound like a very stupid problem.</p>
  
  <p>Cheers ! </p>