-2

How can I build a random team generator using python? I have a team of 60 and want to divide them into 10 groups.

martineau
  • 119,623
  • 25
  • 170
  • 301

1 Answers1

1

Easiest would probably be to just shuffle and slice the original pool:

import random

pool = list(range(60))  # or some other list of length 60
random.shuffle(pool)

teams = [pool[i:i+6] for i in range(0, 60, 6)]
teams
[[28, 7, 59, 43, 2, 39],
 [26, 53, 33, 3, 17, 34],
 [9, 21, 58, 36, 37, 4],
 [57, 38, 56, 15, 23, 1],
 [10, 49, 52, 0, 40, 13],
 [27, 14, 35, 47, 45, 18],
 [12, 46, 6, 55, 11, 30],
 [19, 22, 54, 41, 16, 20],
 [50, 44, 29, 48, 8, 42],
 [5, 51, 25, 31, 32, 24]]
user2390182
  • 72,016
  • 6
  • 67
  • 89