mercredi 21 novembre 2018

Python: How do I randomly mix two lists?

If I generate two random lists for example:

N=5
X=20

parent1 = np.random.choice(X, N, replace=True)
parent2 = np.random.choice(X, N, replace=True)

Would give two lists e.g:

[2,5,1,1,12]
[3,18,4,5,1]

How could I make a new list which is a random mix of the two lists with the same amount of numbers?

e.g.

[2,18,1,5,12]

or

[18,5,1,12,5]

It doesn't matter about order.




Aucun commentaire:

Enregistrer un commentaire