title: Create dynamic menu from os.listdir
body: <p>How do I generate a list of dynamic menu items based on the number of files present in a folder?</p>
  
  <p>The current code retrieves the filenames in the folder, but it needs to generate menu options.</p>
  
  <pre><code>from os import listdir
  from os.path import isfile, join
  
  folder = "path/folder/to/read/"
  
  file_names = [fn for fn in listdir(folder) if isfile(join(folder,fn))]
  print "Select file to manipulate:\n"
  for f in file_names: print #Add iterable menu items here somehow
  </code></pre>
  
  <p>Desired functionality:</p>
  
  <pre><code>"Select file to manipulate: 
  [1] test.csv
  [2] test2.csv
  [3] test3.csv"
  </code></pre>
  
  <p>It should then take the <code>raw_input</code> for <code>1</code>, <code>2</code> or <code>3</code> and select corresponding <code>f</code> in <code>file_names</code>. I will then do <code>folder</code> + <code>ans</code> to create a full path <code>path/folder/to/read/test.csv</code>.</p>
  
  <p>Static example:</p>
  
  <pre><code>while ans:
      print ("""
      [1]. Option 1
      [2]. Option 2
      [3]. Option 3
      """)
      ans = raw_input("Select action: ")
  
      if ans == "1":
          #do something
      if ans == "2":
          #do something else
      if ans == "3":
          #do something different
  </code></pre>