title: How to continue loop when the file is not found
body: <p>I am trying to print the list of files in the date range set by the user. </p>
  
  <p>This is my sample files: Note that there is no "2015-01-01" in the file</p>
  
  <p><a href="https://i.stack.imgur.com/DPoYa.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/DPoYa.png" alt="enter image description here"></a></p>
  
  <p>If I input range from <code>2015-01-02</code> to <code>2015-01-05</code> it will print the list if files. But if I input from <code>2015-01-01</code> to <code>2015-01-05</code> it will result in an error: </p>
  
  <pre><code>OSError: (2, 'No such file or directory', '\\2015-01-01')
  </code></pre>
  
  <p>Is it possible to have try-except-pass or continue so that my loop will still continue and prints <code>2015-01-02</code> to <code>2015-01-05</code>. And just deny the file not found.</p>
  
  <p>This is my current code:</p>
  
  <pre><code>FileNameList = []
  date = start_date
  while date &lt;= end_date:
      folder_name = date.strftime(DATE_FORMAT)
      data_folder = path.join(pathDir, folder_name)
      #print data_folder  
  
      for filefolder in os.listdir(data_folder):      
          filefolder = data_folder + "\\" + filefolder
  
      FileNameList.append(filefolder)
  
      date += delta_one_day
  
  for filefolder in FileNameList:
      for file in os.listdir(filefolder):
          if ".txt" in file:
              filename = filefolder + "\\" + file 
              print filename      
  </code></pre>