title: When walking through files and folders, how do I compare the current filename with the next, in python?
body: <p>I'm running a script that runs through folders and files and use these very simple loops. Now I was wondering how I could compare the current filename with the one that comes next, within this loop?</p>
  
  <pre><code>list_of_files = {}
      for (dirpath, dirnames, filenames) in os.walk(path):
          for filename in filenames:
             print 'I know here I could print: ', filename
             print 'but how could I print: ', filename+1
  </code></pre>
  
  <p>Generally, what I want to accomplish is to compare the two files, select one on certain criteria, compare with the next in the same folder on these criteria - until the end of the folder. In the next folder I would like to do the same again.</p>