Dennis Sweeney <sweeney.dennis...@gmail.com> added the comment:
The help text says this: >>> help(list.index) Help on method_descriptor: index(self, value, start=0, stop=9223372036854775807, /) Return first index of value. Raises ValueError if the value is not present. Emphasis on *first* index. Example: >>> L = [0, 10, 20, 33, 0, 10] >>> L.index(10) 1 >>> L[5] 10 >>> L.index(L[5]) # the same meaning as L.index(10) 1 In your code, when elm has the value 1, it's just the value 1; there's no extra information carried along about where that 1 came from. If elm == 1, then my_list.index(elm) means the same as my_list.index(1). I'd suggest taking any further questions to either StackOverflow or https://discuss.python.org/c/users/ Thanks for the concern, but I'm closing this as "not a bug". Changing this behavior now would be backwards-incompatible and break lots of people's code. ---------- nosy: +Dennis Sweeney resolution: -> not a bug stage: -> resolved status: open -> closed _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue47094> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com