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 -

reflection - How to access the object-members of an object declaration in kotlin -

php - Doctrine Query Builder Error on Join: [Syntax Error] line 0, col 87: Error: Expected Literal, got 'JOIN' -