title: python : IndexError: list index out of range
body: <p>I copy this copy this code from github and try to run it on python. I got the following error. Im new to python and raspberry pi. Please someone sort this out? </p>
  
  <p>Error:</p>
  
  <blockquote>
    <p>if(bool(sys.argv[1]) and bool(sys.argv[2])): IndexError: list index out of range</p>
  </blockquote>
  
  <p>coding:</p>
  
  <pre><code>import time
  import RPi.GPIO as GPIO
  import sys
  
  GPIO.cleanup()
  
  GPIO.setmode(GPIO.BCM)
  
  
  
  Passed = 0
  
  
  pulseWidth = 0.01
  
  
  if(bool(sys.argv[1]) and bool(sys.argv[2])):
  
      try:
          motorPin = int(sys.argv[1])
          runTime = float(sys.argv[2])
          powerPercentage = float(sys.argv[3]) / 100
          Passed = 1
      except:
          exit
  
  if Passed:
  
      # Set all pins as output
      print "Setup Motor Pin"
      GPIO.setup(motorPin,GPIO.OUT)
      GPIO.output(motorPin, False)
      counter = int(runTime / pulseWidth)
  
      print "Start Motor" 
  
      print "Power: " + str(powerPercentage)
      onTime = pulseWidth * powerPercentage
      offTime = pulseWidth - onTime
  
      while counter &gt; 0:
          GPIO.output(motorPin, True)
          time.sleep(onTime)
          GPIO.output(motorPin, False)
          time.sleep(offTime)
          counter = counter - 1
  
      print "Stop Motor"
      GPIO.output(motorPin, False)
  
  
  else:
          print "Usage: motor.py GPIO_Pin_Number Seconds_To_Turn Power_Percentage"
  
  GPIO.cleanup()
  </code></pre>