a = [1, 2, 3, 4, 5, 6]
b = [7, 8, 9, 0]
My goal is to randomly take 3 values from each list and combine them into one new list.
c = [1, 2, 3, 7, 8, 9]
With random.sample
I can pick up values from one list at a time.
x = random.sample(a, 3)
y = random.sample(b, 3)
I could combine the results in several steps but I wonder if there is a cleaner version of this.
Aucun commentaire:
Enregistrer un commentaire