title: Command line prompted errors
body: <p>My program takes 2 or 3 command line parameters:</p>
  
  <p>-s is an optional parameter, indicating a switch in my program later on
  -infile is the file input
  -outfile is to be the written file</p>
  
  <p>I need my program to print an error message and quit if any of the following happen:</p>
  
  <ul>
  <li>the user specifies an infile name that does not end with .genes</li>
  <li>the user specifics an outfile name that does not end with either .fa or .fasta</li>
  <li>the user provides less than 2, or more than 3, parameters</li>
  <li>the user's first parameter starts with a dash, but is not '-s'</li>
  </ul>
  
  <p>I have written:</p>
  
  <pre><code>def getGenes(spliced, infile, outfile):
  spliced = False
  if '-s' in sys.argv:
      spliced = True
      sys.argv.remove('-s')
      infile, outfile = sys.argv[1:]
  if not infile.endswith('.genes'):
      print('Incorrect input file type')
      sys.exit(1)
  if not outfile.endswith('.fa' or '.fasta'):
      print('Incorrect output file type')
      sys.exit(1)
  if not 2 &lt;= len(sys.argv) &lt;= 3:
      print('Command line parameters missing')
      sys.exit(1)
  if sys.argv[1] != '-s':
      print('Invalid parameter, if spliced, must be -s')
      sys.exit(1)
  </code></pre>
  
  <p>However, something is conflicting with some of the conditionals, including the first and last one being contradictory due to the fact that s.argv[1] always unequal to '-s' becuase if 's' were present in argv, it was removed earlier. So I am not sure how to write this correctly...</p>