SHARE
TWEET

Untitled

rickzman Dec 10th, 2019 94 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # Team picking from a group
  2.  
  3. from random import choice
  4.  
  5. team_a = []
  6. team_b = []
  7.  
  8.  
  9. players = ["Harry", "Hermione", "Neville", "Ginny", "Frank" , "Rick" , "George"]
  10. #players = ['Harry' ]
  11. #players = ['A', 'B','C', 'D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S']
  12.  
  13. # Add players to a team function
  14. def build_team(team):  
  15.     player_picked = choice(players)
  16.     team.append(player_picked)
  17.     players.remove(player_picked)
  18.  
  19. number = len(players)
  20.  
  21. while len(players):
  22.         build_team(team_a)
  23.         if len(players)>0:
  24.             build_team(team_b)
  25.  
  26. # check for even/odd teams
  27. if number % 2 != 0:
  28.     print("There isn't and even number of player. Team A has the extra player.")
  29.            
  30. print("Team A>")
  31. print (team_a)
  32. print("Team B>")
  33. print (team_b)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top