This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author rhettinger
Recipients chetanpalliwal13, rhettinger
Date 2020-10-19.07:29:45
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1603092585.59.0.501369556967.issue42026@roundup.psfhosted.org>
In-reply-to
Content
> 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.
History
Date User Action Args
2020-10-19 07:29:45rhettingersetrecipients: + rhettinger, chetanpalliwal13
2020-10-19 07:29:45rhettingersetmessageid: <1603092585.59.0.501369556967.issue42026@roundup.psfhosted.org>
2020-10-19 07:29:45rhettingerlinkissue42026 messages
2020-10-19 07:29:45rhettingercreate