import numpy as np def pick(lst): if len(locals()) < 2: n = 1 lst = np.array(lst) # i = np.random.permutation(len(lst)) i = np.random.randint(len(lst)) k = lst[i] return k, i