Python: get index of each item in list with duplicates -


how index of each item in list, including duplicates? far know python list.index give me first index of duplicated item, this.

registros = ["celda", "celda", "test", "celda", "celda", "celda"]     item in registros:         index_found = registros.index(item)         print(str(index_found) + " " + dato) 

outputs:

0 celda 0 celda 2 test 0 celda 0 celda 0 celda 

so how do (as simple possible) desired output?:

0 celda 1 celda 2 test 3 celda 4 celda 5 celda 


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

Qt QGraphicsScene is not accessable from QGraphicsView (on Qt 5.6.1) -

What is happening when Matlab is starting a "parallel pool"? -