Advertisement
Antypas

Choost Two Teams

Apr 11th, 2020
279
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.75 KB | None | 0 0
  1. #Adding players to different teams
  2. from random import choice
  3.  
  4. teamA = []
  5. teamB = []    # Create two empty lists for teams A and B
  6.  
  7. players = ['Harry', 'Hermione', 'Neville', 'Ginny', 'Myself']
  8. #players = ['Harry', 'Ginny']
  9. #players = ['Harry']
  10. #players = []
  11. #players = ['A', 'B', 'C', 'D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R']
  12.  
  13. def add_player_to_team(team):
  14.     player_picked = choice(players)
  15.     team.append(player_picked)
  16.     players.remove(player_picked)
  17.    
  18. # Add a player to each team
  19. for index in range(len(players)//2*2):
  20.     if index%2 == 0:
  21.         add_player_to_team(teamA)
  22.     elif index%2 == 1:
  23.         add_player_to_team(teamB)
  24.  
  25. print("teamA ",teamA)
  26. print("teamB ",teamB)
  27. print("one player out of luck ", players)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement