For example I have the following list of lists:
matrix = [['.', 'W', '.'],
['.', 'W', '.'],
['W', '.', '.']]
I want to have a list with all rows, column indexes.
In this answer they show how to do it for a single list.
However I want to do it for nested list. There are more then one examples of this like this and this
So this works for me:
l = [[(i,j) for j,el in enumerate(row) if el == 'W'] for i,row in enumerate(matrix)]
flat_list = [item for sublist in l for item in sublist]
>> [(0, 1), (1, 1), (2, 0)]
However how would I do this with one list comprehension statement?