Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # 2 5 teamsshufflepop.py
- # With Thanks mainly to Natalie S
- from random import shuffle
- teamA = [] # Create two empty lists for teams A and B
- teamB = []
- players = ['Afiki', 'Bozo', 'Ching', 'Don', 'Emmet', 'Fox', 'Shoes' ]
- #players = ['Afiki', 'Bozo', 'Ching', 'Don', 'Emmet', 'Fox']
- #players = ['Ching', 'Don']
- #players = ['Emmet']
- #players = []
- #players = ['A', 'B', 'C', 'D','E','F','G','H','I','J','K','L','M','N','O','P','Q'] #,'R'
- shuffle(players) # to shuffle players list Once only.
- def add_player(team):
- # shuffle(players) # to shuffle players list every round
- playerPicked = players.pop() #pop item from list and assign to variable
- team.append(playerPicked) #add popped player to list
- #number of times to repeat
- repeat = len(players)//2
- for i in range(repeat):
- add_player(teamA)
- add_player(teamB)
- #Print out the teams
- print("Team A:", ', '.join(teamA))
- print("Team B:", ', '.join(teamB))
- if players:
- print("Benched:", ', '.join(players))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement