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 -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -