Raymond Hettinger <raymond.hettin...@gmail.com> added the comment:

> If the index() is working fine. why my previous attached
> code sample is returning 0 for each time I try to get 
> the index for element 11 in the list.

Your code is buggy.  It assumes that list.index() changes its starting point as 
your for-loop iterates.   However, the documented and correct behavior of 
list.index() is that unless a *start* argument is provided, the search always 
starts at position zero and returns the index of the first matching target 
value:  

    >>> help(list.index)
    Help on method_descriptor:

    index(self, value, start=0, stop=9223372036854775807, /)
        Return first index of value.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue42026>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to