Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR TYPESCRIPT

how to get index of duplicate elements in list python

list_values = ['A', 'B', 'A', 'C', 'E']

def indices(lst, item):
    return [i for i, x in enumerate(lst) if x == item]

ind_A = indices(list_values, "A")
print(ind_A)
# [0,2]
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #index #duplicate #elements #list #python
ADD COMMENT
Topic
Name
3+2 =