The problem is that list.index() also works on the basis of equality, not identifier, so it returns the index for the first equal element in the list.
And for lists, equality is checked by first checking that they are both the same list (that is, if both compared lists are the same list object, it immediately returns True), otherwise it is based on the equality of all elements contained in it that is, if two lists have all the elements in the same order, then these lists are equal, therefore empty lists are always equal. Example -
>>> a = [] >>> b = [] >>> a == b True >>> a is b False
source share