You have to call your program with at least two command-line arguments, like so:
python2 yourscript.py 23 42
Otherwise, the sys.argv
array has less than 3 elements and you'll access it outside of its range.
It is good practice to explicitly check the number of command-line arguments before trying to access them:
if len(sys.argv) < 3:
print "This program needs at least two arguments."
sys.exit(1)
Then your program will print a useful error message instead of an ugly exception.