# using rindex()
test_string = "abcabcabc"
# using rindex()
# to get last element occurrence
res = test_string.rindex('c')
# printing result
print ("The index of last element occurrence: " + str(res))
OUTPUT:
The index of last element occurrence: 8
l = [1,2,3,4,5]
l[::len(l)-1]
# To get first and last index of list or string
list_a = [1,2,3,4]
first_index = list_a[0] # 1
last_index = list_a[-1] # 4
str_a = "abc"
first_index_str = str_a[0] # a
last_index_str = str_a[-1] # c
# To find first and last index of char in string
str_b = "abcabcdec"
first_index_of_c = str_b.index("c") # 2
last_index_of_c = str_b.rindex("c") # 8
[some_list[0], some_list[-1]]