title: File not in directory, user re-enters file name (loop) - Python
body: <p>What I want to do is have it so when the user enters the file name to be opened and then read, if the file inputted is not found in the directory rather than an error message appearing on the shell it should ask the user to input the file name again.</p>
  
  <pre><code>print("\nEnter the name of the file you would like to encrypt, ensuring that you type .txt afterwards.")
  filename = input()
  
  try:
      sample=open(filename, 'r').read()
  except IOError:
      print ("there is no such a file")
  </code></pre>
  
  <p>All the code needs to do now is just loop it so if the user still doesn't enter a file name where the file to be uploaded isn't then it should ask the user to re-enter the name of the file they want uploaded.</p>
  
  <p>I only want text files to be uploaded by the way.</p>
  
  <p>Thanks</p>