I'm iterating over a list (numpy array with one dimension to be exact) and I need to pick an index form this list that is random and different than current iterator.
The most important thing is constant and equal probability over the range.
list = ['a','b','c','d']
for idx , e in enumerate(list):
return random.randrange(len(list)-1) # but without possibility of geting idx
-- EDIT -- Wouldnt that work:
x = np.array([1,2,3,4])
for idx, e in enumerate(x):
l = list(range(0, len(x)))
l.pop(idx)
res = random.choice(l)
print(idx, res)
random.choice()