Here is my code, I have two lists and a list that contains the two lists (my real lists are more complex but I’m trying to simplify them in order to focus on the main problem)
The index is the part within square brackets. So for list[i], your index is i. Python is telling you that the index must be an int or a slice, not a list.
In the for i in list: line, the variable i isn’t set to the place in the list, it’s set to each element in turn. So I suspect you were intending something closer to:
I have to get, at a specific step of the loop, what is the list (a,b or c) a specific item comes from.
For example, if the algorithm gives me [4,5,6,2], I expect → ‘b’
lists_of_lists = {
'a': [[1,2,3], [1,4,5]],
'b': [[8,6,5], []]
}
for lists_name, lists in lists_of_lists.items():
# do something with the name/key
for sublist in lists:
# and so on