I have a bunch of frozensets and they are all subsets of a list. What I want to find out is the position of each element of the frozen set in the list.
for e.g.:
a = frozenset([1])
b = frozenset([2, 3])
l = [1, 2, 3, 4]
Now I already know the frozensets are a subset of the list l.
What I want is the index position of items in the list i.e. when I am checking for a, the function should return the index position for 1 in the list l i.e. [0].
Similarly for b, it should first return [1, 2].
If you already know
aandbare subsets, just use a list comprehension to gather indices of values that are members; use theenumerate()function to supply the indices:where
subsetis one of yourfrozensetinstances.Demo: