[Solved] IndexError: list index out of range Python Argument Input [closed]


check this question out and see if it can help
python and sys.argv
add this after your “def…”

if len(sys.argv) < 3 :
  print "Please enter two arguments"
  sys.exit(1)

and change your other one

if len(sys.argv) > 3 :
        print "Enter two arguments only"
        sys.exit(1)

to

if len(sys.argv) > 4 :
        print "Enter only two arguments after the program"
        sys.exit(1)

even easier

if len(sys.argv) >= 0 | len(sys.argv) < 3 :
  fieldindex = int(sys.argv[1])-1  
else:
  sys.exit("enter up to 2 args")

2

solved IndexError: list index out of range Python Argument Input [closed]