Python: list is populating with wrong order?
The question is not a Blender question, but anyway...
So use append(currentBone) instead of insert(index, currentBone), to have [IKB3, IKB2, IKB1].
Or use insert(0, currentBone) instead of insert(index, currentBone) to have [IKB1, IKB2, IKB3].
But concerning &quot;why&quot; your usage of insert does not work:
Step1:
bone_list is empty and index is 2.
So bone_list.insert(2, IKB3) gives bone_list = [IKB3]. Explanation: Python tolerates that even if there is no element at position 2.
And index becomes 1.
Step2:
bone_list.insert(1, IKB2) gives bone_list = [IKB3, IKB2]. Explanation: still no element at position 1 (IKB3 is at position 0), so IKB2 is added at the end (which is the closest position to '1').
And index becomes 0.
Step3:
bone_list.insert(0, IKB1) gives bone_list = [IKB1, IKB3, IKB2]. Explanation: there is now an element at 0, so as expected Python add IKB1 before it.