If I have a 2 dimensional list, how can I generate a list of indices for a specific element in that 2D list?
For example, if I have the list
two_d_list = [[0, 1, 0, 0], [1, 1, 0, 0], [0, 0, 0, 1]]
How could I make a list with this format
index_list = [[0, 1], [1, 0], [1, 1], [2, 3]]
which is the list of 2 dimensional indexes of all 1s in two_d_list.
The format of
index_list = [(0, 1), (1, 0), (1, 1), (2, 3)]
would also work. I just need to retrieve the indices.