Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

index duplicates 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]
Comment

PREVIOUS NEXT
Code Example
Python :: how to show installed tkinter fonts 
Python :: string list to list 
Python :: kdeplot python 
Python :: python indentation 
Python :: python ascii to string 
Python :: python doctype 
Python :: how to print in python 
Python :: python jinja2 from string 
Python :: how to append to a list in python 
Python :: stack program in python3 
Python :: matplotlib pie chart order 
Python :: python IndexError: list assignment index out of range 
Python :: python evaluate string 
Python :: How to count the occurrence of certain item in an ndarray? 
Python :: python tree 
Python :: __mul__ 
Python :: python float range 
Python :: newline in python gives an extra one 
Python :: discord.py read custom status 
Python :: create data frame in panda 
Python :: python outlook 
Python :: join 3 dataframes by index python 
Python :: text generate gpt 2 huggingface 
Python :: tuple in python 
Python :: {% load humanise %} 
Python :: adding strings together in python 
Python :: prevent selenium from closing 
Python :: 2d arrays with rows and columns 
Python :: df set index 
Python :: how to exit a function python 
ADD CONTENT
Topic
Content
Source link
Name
3+3 =