I am working on a list of lists and I want indices of the list from where an element starts duplicating. Given the list is sorted already by 2nd key value of each sublist in descending order IN
A = [[11, 89, 9], [12, 89, 48], [13, 64, 44], [22, 64, 56], [33, 64, 9]]
I want the program to reflect two index ranges.
1. 0 to 1 for 89 at 0th and 1st sublist
2. 2 to 4 for 64 at 2nd, 3rd and 4th sublist
how to achieve this ??
I tried to loop as the list is already sorted:
for i in range(0,len(A)-1):
if A[i][1] == A[i+1][1]:
print(i)
but it is returning only the starting index not the ending ones.