Advertisement
kevinbocky

pick_teams3adjusted.py

Jan 27th, 2019
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1.  
  2.  
  3. team1 = []
  4. team2 = []
  5. team3 = []
  6. team4 = []
  7. players = ["Kevin", "Michael","Erica","Serge", "Dennis", "Judith", "Renee", "Ruben", "Jan", "Ellen", "Niels", "Lindsay","Bonny"]
  8.  
  9.  
  10. #make a function that randomly picks players and divides them between team1 to team4 spreading them as even as possible
  11. def pickteams():
  12. import random
  13. import math
  14. count = len(players)
  15. playerbase = len(players)
  16. for i in range (int(count)):
  17. if len(team1) <= len(team2):
  18. p1 = random.choice(players)
  19. team1.append(p1)
  20. players.remove(p1)
  21. count = count - 1
  22. elif len(team2) < len(team3):
  23. p2 = random.choice(players)
  24. team2.append(p2)
  25. players.remove(p2)
  26. count = count - 1
  27.  
  28. elif len(team3) < len(team4):
  29. p3 = random.choice(players)
  30. team3.append(p3)
  31. players.remove(p3)
  32. count = count - 1
  33.  
  34. elif len(team4) < len(team1):
  35. p4 = random.choice(players)
  36. team4.append(p4)
  37. players.remove(p4)
  38. count = count - 1
  39.  
  40.  
  41.  
  42. print(team1)
  43. print(team2)
  44. print(team3)
  45. print(team4)
  46.  
  47.  
  48. pickteams()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement