0

Because .index() always returns the first occurrence of an element I'm struggling to find all the indexes of an element with multiple occurences but in a multidimensional list. For example:

main_list=[["Name1",[21,22,25]],
          ["name2",[25,21,24]],
          ["name3",[29,21,24]]]

How would I find all indexes of main_list.index(25)?The search should return the "name1" and "name2"

Largecooler21
  • 147
  • 3
  • 12
  • 1
    How should the "index" look, then? What is the element you are looking for, exactly? A name, or a number, or a sub-list that has a certain name? Please show an example "search query" and the expected result. – tobias_k Nov 09 '17 at 14:00
  • A jagged list does not have dimensions in the conventional sense, so your question is quite unclear. – Moses Koledoye Nov 09 '17 at 14:08
  • What should your search return? `Name1` or `Name1:2`? Also: don't you find the answer in [this](https://stackoverflow.com/questions/9553638/python-find-the-index-of-an-item-in-a-list-of-lists) or [this](https://stackoverflow.com/questions/6294179/how-to-find-all-occurrences-of-an-element-in-a-list) SO thread? – Mr. T Nov 09 '17 at 14:12
  • Wait - you asked [a similar question](https://stackoverflow.com/questions/47202594/indexing-duplicates-python) within 10 minutes? Why didn't you combine them? – Mr. T Nov 09 '17 at 14:49

0 Answers0