[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

how to get INDEX count, or last number of Index

On 24/05/2018 01:46, bartc wrote:
> On 24/05/2018 00:44, Terry Reedy wrote:
>> On 5/23/2018 5:56 PM, Rob Gaddi wrote:
>>> On 05/23/2018 02:51 PM, asa32sd23 at gmail.com wrote:
>>>> s = "kitti"
>>>> 0,1,2,3,4
>>>> k,i,t,t,i
>>>> how do i retrieve '4'. i know i can do a len(s)-1,
>> Use -1, which is the same as len(s)-1 but faster.
> This illustrates one problem with having a example sequence of values 
> being identical to the indices of those values.
> I would have used 10,20,30,40,50 so there could be no such mix-up.

Hmm, although my observation is valid, that's not the case here, as the 
0,1,2,3,4 /are/ the indices! Not the list of values of which they are 
trying to access the '4', and which /could/ be obtained with the -1 
index some people are talking about, that added to the confusion.