Given the following list:
list_ex = ['s1', 's2', 's1', 's4', 's2', 's3', 's1']
How can all the indices of all the distinct elements, be found?
For example, for s1
, this would be locations [0, 2, 6]
.
I think that I can do this by running a loop over the distinct elements list(set(list_ex))
, and then do a np.where
to find the location?