mercredi 26 mai 2021

Problems while creating a random numpy vector with unique elements?

I am creating lists like this:

In:

x = [[[random.randint(1,1000), random.randint(0,2)] for i,j in zip(range(1), range(1))][0] for i in range(5)]

Out:

[[76, 0], [128, 2], [194, 2], [851, 2], [123, 1]]

However, what is the most efficient way of making the first element of the sublist unique? It seems that randint doesnt have this option. How can I force 76, 128, 194, 851, 123 to be unique?




Aucun commentaire:

Enregistrer un commentaire