jeudi 16 avril 2020

How to randomly select n items from permutation list in Python

I want to select some random set of grouped items from permutation list. How to do it in a single function call or maybe with minimal code. For Eg:

A=[1,2,3]

If I input list A and a requirement (say 2) means, from all possible permutations

[1,2,3], [1,3,2], [3,1,2], [3,2,1],[2,1,3],[2,3,1]

I have to get randomly two list. Should return : [3,1,2],[2,1,3] or any other random two lists/tuple




Aucun commentaire:

Enregistrer un commentaire