mardi 31 mars 2020

generate list of no repeated tuples and doesn't have both of (a,b) and (b,a) tuples, python

How can I generate a list of tuples whose elements are not repeated? In addition, if there is (a,b) tuple in list, (b,a) would not be generated in this list.

I use code below from here, but it doesn't provide second condition:

[tuple(i) for i in np.random.randint(5242, size=(500,2))]



Aucun commentaire:

Enregistrer un commentaire