[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/2018 22:51, 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

Not for that trivial task. But you can create your own:

  def upb(x): return len(x)-1     # 'upb' means 'upper-bound'

  print (upb("kitti"))            # output: 4