jeudi 8 juin 2017

random element from a list

Is there a way in python to select a random element form a list without considering a current element?

In other word, I want to do this

L=[1,2,3,4,5,6,7,8,9,10]
i=0
while(i<len(L):
  random.choice(L-L[i])
  i+=1

For example, at iteration 0 I do not want to have the element 1 and at iteration 1 I do not want to have the element 2.




Aucun commentaire:

Enregistrer un commentaire