I have a two dimensional list and for every list in the list I want to print its index and for every element in each list I also want to print its index. Here is what I tried:
l = [[0,0,0],[0,1,1],[1,0,0]] def Printme(arg1, arg2): print arg1, arg2 for i in l: for j in i: Printme(l.index(i), l.index(j)) But the output is:
0 0 # I was expecting: 0 0 0 0 # 0 1 0 0 # 0 2 1 0 # 1 0 1 1 # 1 1 1 1 # 1 2 2 0 # 2 0 2 1 # 2 1 2 1 # 2 2 Why is that? How can I make it do what I want?
list.indexshort circuits upon finding the first value equal to your search value.