If I have a list such as:
a = [1, 2, 3, 3, 4, 5]
And I want to choose a random element from this list using np.random.choice
, and let's say that results in me getting the value 3, how am I supposed to get the correct index of the element 3 and not just automatically the first 3 that appears?
I know for list of unique values, I can use .index
to get it, but not sure how to go about for non-unique values.
Thanks!