Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Adding players to different teams
- from random import choice
- teamA = []
- teamB = [] # Create two empty lists for teams A and B
- players = ['Harry', 'Hermione', 'Neville', 'Ginny', 'Myself']
- #players = ['Harry', 'Ginny']
- #players = ['Harry']
- #players = []
- #players = ['A', 'B', 'C', 'D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R']
- def add_player_to_team(team):
- player_picked = choice(players)
- team.append(player_picked)
- players.remove(player_picked)
- # Add a player to each team
- for index in range(len(players)//2*2):
- if index%2 == 0:
- add_player_to_team(teamA)
- elif index%2 == 1:
- add_player_to_team(teamB)
- print("teamA ",teamA)
- print("teamB ",teamB)
- print("one player out of luck ", players)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement