lundi 21 septembre 2020

How to compare two random lists in python?

I have 12 people who i need to divide into 2 different teams. What i need to do is pick random 6 numbers between 0 and 11 for the first team and do the same for the second one with no overlap. What is the most efficient way to do this?

import random

A = random.choice([x for x in range(12)])

B = random.choice([x for x in range(12) if x != A])

C = random.choice([x for x in range(12) if (x != A) and (x != B)])

team1 = random.sample(range(0, 12), 6)
team2 = random.sample(range(0, 12), 6)

This is what i wrote so far. Any help is appreciated.




Aucun commentaire:

Enregistrer un commentaire