dimanche 29 mars 2020

How to generate a random such that the previou number does not repeat again?

Hi suppose I have this list l = [0,1,2,3,4,5,6,7,8,9]. I select a random number from this list using the random.choice() method. I get the output as 4. But for the second iteration, I don't need 4 again rather a different number from the remaining list say I got now 6. Now here I again want to add the4 back to the list and pop 6 and same for the next iteration to make sure that every time I get unique random value ut also making sure (if I am popping a number from the list) I add that number back to the list in the next iteration. For the record, is there any package available in python to provide such unique random number?




Aucun commentaire:

Enregistrer un commentaire