title: "sys.argv[x]" is out of range
body: <p>I must run the exact command:</p>
  
  <pre><code>python3 main.py flip pattern.ppm &gt; flippedpattern.ppm
  </code></pre>
  
  <p>on the following code:</p>
  
  <pre><code>def main(args):
      if sys.argv[1] == "flip":
          fileName = sys.argv[2]
          method = read_ppm(fileName)
          print(method.flip())
          return
  if __name__ == '__main__':
      sys.exit(main(sys.argv))
  </code></pre>
  
  <p>I have a ppm file and I am trying to manipulating it using another module, but it keeps telling me sys.argv[4] is out of range when assigning it to the variable 'outputFile'</p>
  
  <p>The code executed should be essentially this for the flip command</p>
  
  <pre><code>method = "flip"
  method = read_ppm("pattern.ppm")
  f.write(method.flip())
  </code></pre>
  
  <p>Doing exactly that using the repl in visual studio leads to success but when I try to run it from the command line through the main module it doesn't work.  Why is this?  Does the '>' character somehow interfere with sys.argv or am I making a clear counting mistake that I can't see?</p>
  
  <p>The else statement would account for the input not catching and simply printing, using the input</p>
  
  <pre><code>python3 main.py flip pattern.ppm
  </code></pre>
  
  <p>without any file redirect.</p>