Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from random import choice
- '''
- Create a list of empty lists for teams and a list of player names, then determine how many players
- will be on each team by dividing the number of players by the number of teams and rounding into an integer
- '''
- teams = [[],[],[],[]]
- players = ["Bob", "Joe", "Ty", "Cat", "Mike", "Sam", "Carl", "Jen", "Dave"]
- t_size = int((len(players)/len(teams)))
- print("Team size is " + str(t_size) + "!")
- #main picking function chooses a player and adds them to current team list
- def play_picking(current_team, p_list):
- player = choice(p_list)
- current_team.append(player)
- p_list.remove(player)
- #Build team roster
- def make_roster(tlist):
- #iterate through each team in the list and build their roster
- for i in tlist:
- #make the first player choice automatically so (len(i) % tisize) is not 0 initally
- play_picking(i, players)
- #continue adding players until the appropriate t_size is reached
- if len(i) % t_size > 0:
- play_picking(i, players)
- #leftover players added to random teams
- if teams != []:
- print("Leftover players will be assorted randomly!")
- team = choice(tlist)
- play_picking(team, players)
- #run player picking function and print teams
- make_roster(teams)
- print players
- print teams
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement