I am trying to search a 2D array of characters and return the array indices, (x_T,y_T), of all of the letter T's in the array. I figure this could easily done with two stacked for loops but I was curious to know if it could be done my efficiently using list comprehension. I have tried things like:
TPos = [[x, y] for x in range(0, len(array[x])) for y in range(0, len(array[x][y])) if array[x][y] == 'T']
But I am getting errors to do with array bounds. Could someone point me in the right direction. Cheers, Jack
Edit
Now trying to use 'ndenumerate' like so:
TPos = [pos for pos, x in numpy.ndenumerate(array) if x == "T"]