Advertisement
kevinbocky

pick_teams.py

Jan 26th, 2019
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. #import the random function
  2. import random
  3.  
  4. team1 = []
  5. team2 = []
  6. players = ["Kevin", "Michael","Erica","Serge", "Dennis", "Judith"]
  7.  
  8.  
  9. #make a function that randomly picks players and divides them between team1 and team2
  10. def pickteams():
  11. count = len(players)
  12. for i in range (int(count)):
  13. if int(count)%2 ==0:
  14. p1 = random.choice(players)
  15. team1.append(p1)
  16. players.remove(p1)
  17. count = count - 1
  18. else:
  19. p2 = random.choice(players)
  20. team2.append(p2)
  21. players.remove(p2)
  22. count = count - 1
  23.  
  24.  
  25. print(team1)
  26. print(team2)
  27.  
  28.  
  29. pickteams()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement