You could do this using List comprehension and enumerate
Code:
lst=[["a", "b", "c"], ["d", "e", "f"], ["g","h"]]
check="a"
print ["{} {}".format(index1,index2) for index1,value1 in enumerate(lst) for index2,value2 in enumerate(value1) if value2==check]
Output:
['0 0']
Steps:
- I have enumerated through the List of List and got it's index and list
- Then I have enumerated over the gotten list and checked if it matches the
check variable and written it to list if so
This gives all possible output
i.e.)
Code2:
lst=[["a", "b", "c","a"], ["d", "e", "f"], ["g","h"]]
check="a"
print ["{} {}".format(index1,index2) for index1,value1 in enumerate(lst) for index2,value2 in enumerate(value1) if value2==check]
Gives:
['0 0', '0 3']
Notes:
- You can easily turn this into list of list instead of string if you want