How to pass command line arguments through Blender without IndexError thrown? I am trying to execute my command with two arguments in terminal:
blender -b Scripting_Testing.blend -P background_job.py -- 1 2

I have used:
import sys

try:
    index = sys.argv.index(&quot;--&quot;) + 1
except ValueError:
    index = len(sys.argv)
sys.argv = sys.argv[index:]
....
....
foot_position = sys.argv[1]
angle_movement = sys.argv[2]

(Used from Here)
I get:
IndexError: list index out of range
All the parameters before &quot;--&quot; (+ 1 makes it inclusive) have been skipped here. The second line overrides the sys.argv to hold only items that go after &quot;--&quot;, which is an array of length 2 containing [1, 2].
index = sys.argv.index(&quot;--&quot;) + 1
sys.argv = sys.argv[index:]

Array indices start from 0. You are trying to access a third parameter here
angle_movement = sys.argv[2]

This causes the out of index exception.
Should be
foot_position = sys.argv[0]
angle_movement = sys.argv[1]