Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- team1 = []
- team2 = []
- team3 = []
- team4 = []
- players = ["Kevin", "Michael","Erica","Serge", "Dennis", "Judith", "Renee", "Ruben", "Jan", "Ellen", "Niels", "Lindsay"]
- #make a function that randomly picks players and divides them between team1 to team4 spreading them as even as possible
- def pickteams():
- import random
- import math
- count = len(players)
- playerbase = len(players)
- for i in range (int(count)):
- if int(count)%2 ==0 and len(team1) < 0.25 * (playerbase):
- p1 = random.choice(players)
- team1.append(p1)
- players.remove(p1)
- count = count - 1
- elif int(count)%2 != 0 and len(team2) < 0.25 * (playerbase):
- p2 = random.choice(players)
- team2.append(p2)
- players.remove(p2)
- count = count - 1
- elif int(count)%2 ==0 and len(team3) < 0.25 * (playerbase):
- p3 = random.choice(players)
- team3.append(p3)
- players.remove(p3)
- count = count - 1
- elif int(count)%2 != 0 and len(team4) < 0.25 * (playerbase):
- p4 = random.choice(players)
- team4.append(p4)
- players.remove(p4)
- count = count - 1
- print(team1)
- print(team2)
- print(team3)
- print(team4)
- pickteams()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement