Python: Indexing list for element in nested list
- by aquateenfan
I know what I'm looking for. I want python to tell me which list it's in.
Here's some pseudocode:
item = "a"
nested_list = [["a", "b"], ["c", "d"]]
list.index(item) #obviously this doesn't work
here I would want python to return 0 (because "a" is an element in the first sub-list in the bigger list). I don't care which sub-element it is. I don't care if there are duplicates, e.g., ["a", "b", "a"] should return the same thing as the above example.
Sorry if this is a dumb question. I'm new to programming.