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, asa32s...@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.

Because I assumed here that the OP wanted the index of the last value, the '4' they said they wanted, not the last value itself which would be 'i'.

And actually, the subject line seems to confirm that.

In that case, using a '-1' index won't work.

--
bartc
--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to