title: How do I validate both a string and an integer input in python?
body: <p>My goal is to print lines of text into a new document when the user enters a specific year. So far, that part works fine. However, I'm not sure how to handle the user typing "all" to signify they want to copy all data into the new file. You can see my failed attempts at trying to make sense of the trial and except blocks below: </p>
  
  <pre><code>filename = input("Enter an output file name: ")
  file_write = open(filename, 'w')
  file_read = open("polio.txt")
  user_year = input("Enter a year: ")
  while True:
      try:
          for line in file_read:
              year = int(line[68:74])
              millenium = int(line[68:69])
              century = int(line[68:70])
              decade = int(line[68:71])
              user_year == int(user_year)
              if user_year == year:
                  file_write.write(line)
              if user_year == millenium:
                  file_write.write(line)
              if user_year == century:
                  file_write.write(line)
              if user_year == decade:
                  file_write.write(line)
      except ValueError:
          if user_year == {"", "all", "ALL"}:
                  file_write(line[:74])
          file_read.close
  </code></pre>
  
  <p>Essentially, all I need to do is find a way to compare the years the user wants to the ones in the text file while also evaluating an empty string and a string containing the phrase "ALL" or "all"</p>