I want to write a program to partition a list of names equally into a dictionary of names and their teams and the problem is I don't know how to distribute team_list to players
import random
team_list = ['A', 'B']
players = ['Hosein', 'Maziar', 'Akbar', 'Nima', 'Mehdi', 'Farhad', 'Mohamad', 'Khashayar', 'Milad', 'Mostafa',
'Amin', 'Saeed', 'Pooya', 'Pooria', 'Reza', 'Ali', 'Behzad', 'Soheil', 'Behrooz', 'Shahrooz', 'Saman', 'Mohsen']
def team(player_list):
random.shuffle(player_list)
return [player_list[i::2] for i in range(2)]
print(team(players))
Aucun commentaire:
Enregistrer un commentaire