title: How to get user input to search a file in Python?
body: <p>I have this code that searches all the files from the given directory, but I want to change it so that it can search a file from the users input? and then ask again if the file is not found? The following code i have is:</p>
  
  <pre><code>import os
  import sys
  from stat import *
  
  
  def depthsearch(directory):
      for files in os.listdir(directory):
          fileItem = os.path.join(directory, files)
          fileItemStatInfo = os.stat(fileItem)
          if S_ISDIR(fileItemStatInfo.st_mode):
              depthsearch(fileItem)
          elif S_ISREG(fileItemStatInfo.st_mode):
              print("Found File:", fileItem)
  
  depthsearch("C:")
  </code></pre>