Advertisement
scarygarey

lists_2_teams

Jan 12th, 2020
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. from random import shuffle
  2. # initialises the three lists
  3. TeamA=[]
  4. TeamB=[]
  5. players=["Dawn", "Sarah", "Laura", "Carrie Anne","Trish","Caroline","Teresa","Julie"]
  6.  
  7. # function to randomly sort players into team
  8. def sort_players(team):
  9. shuffle(players)
  10. name =players.pop()
  11. team.append(name)
  12.  
  13. #main program to sort a list of players in to 2 teams
  14. x=int(len(players))
  15. x=int(x/2)
  16. for i in range(x):
  17. sort_players(TeamA)
  18. sort_players(TeamB)
  19.  
  20. print("TeamA players are ",TeamA)
  21. print("TeamB players are ",TeamB)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement