title: Python - Choose directory that contains a specific string
body: <p>The following code prints a list of directories that all happen to contain a 3 letter code, Example:</p>
  
  <p>//Server/Jobs/2016\AAM - 'areallylongfilename'/</p>
  
  <p>//Server/Jobs/2016\CLM - 'areallylongfilename'/</p>
  
  <p>//Server/Jobs/2016\COO - 'areallylongfilename'/</p>
  
  <pre><code>import os
  basepath = '//Server/Jobs/2016'
  for fname in os.listdir(basepath):
      path = os.path.join(basepath, fname)
      if os.path.isdir(path):
          print(path)
  </code></pre>
  
  <p>How can I get one directory from the list based on the 3 letter code?</p>