 <pre><code>for i, fname in enumerate(dirList): print "%s) %s" % (i + 1, fname) selectedInt = int(raw_input("Select a file above: ")) selected = dirList[selectedInt - 1] </code></pre> <p>However, note that there is no error correction done. You should catch cases, where the input is no integer.</p>