how to take the last index of an array in python code example
Example 1: get last element of array python
some_list[-1]
Example 2: how to get last element in numpy array
In [10]: arr = numpy.array([1,23,4,6,7,8])
In [11]: [(arr[i], arr[-i-1]) for i in range(len(arr) // 2)]
Out[11]: [(1, 8), (23, 7), (4, 6)]
Example 3: last index in python
test_string = "abcabcabc"
res = test_string.rindex('c')
print ("The index of last element occurrence: " + str(res))
OUTPUT:
The index of last element occurrence: 8