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

how to get INDEX count, or last number of Index


On 23/05/18 22:56, 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, but i assume there 
>> is a function that gives me last number of index
>>
>> thanks
>>
> 
> Not sure I'm following your question; len(s)-1 is much faster than 
> enumerating over the string just to get the last index.
> 

-1 is even faster.


-- 
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence