kevinbocky

pick_teams2.py

Jan 26th, 2019
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 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", "Renee", "Ruben", ]
  7.  
  8.  
  9. #make a function that shuffles players in list and removes the last one from the list and then adds them between team1 and team2
  10. def pickteams():
  11. from random import shuffle
  12. count = len(players)
  13. for i in range(int(count)):
  14. if int(count)%2 == 0:
  15. shuffle(players)
  16. p1 = players.pop()
  17. team1.append(p1)
  18. count = count - 1
  19. else:
  20. shuffle(players)
  21. p2 = players.pop()
  22. team2.append(p2)
  23. count = count - 1
  24.  
  25. print(team1)
  26. print(team2)
  27.  
  28. pickteams()
Advertisement
Add Comment
Please, Sign In to add comment