Advertisement
g0thy

List2

Dec 9th, 2019
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.89 KB | None | 0 0
  1. from random import choice
  2. from random import shuffle
  3. from random import sample #Just preparing for the next assignment
  4.  
  5. teamA = []
  6. teamB = []
  7.  
  8. players = ['Alpha', 'Bravo', 'Charlie', 'Delta', 'Echo', 'Foxtrot', 'Golf', 'Hotel', 'India', 'Juliet', 'Kilo', 'Lima', 'Mike', 'November', 'Oscar', 'Papa', 'Qubec', 'Romeo', 'Sierra', 'Tango', 'Uniform', 'Victor', 'Whiskey', 'Xray', 'Yankee', 'Zulu']
  9.  
  10. def add_player_to_team(team):   #Shuffle the list of players, remove the first one and add it to the team
  11.     shuffle(players)
  12.     player_picked = players.pop(0)
  13.     team.append(player_picked)
  14.  
  15. playersLen = len(players) #How many players?
  16.  
  17. loopCount = 0
  18.  
  19. for loop in range(playersLen): #stop when you run out of players
  20.     for x in players:    
  21.         add_player_to_team(teamA)
  22.         add_player_to_team(teamB)
  23.    
  24. print('Team A= ', teamA)    #printout the teams
  25. print('Team B= ', teamB)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement