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))
- '''
- def play_picking(current_team, p_list):
- player = choice(p_list)
- current_team.append(player)
- p_list.remove(player)
- '''
- #main function that takes team list and player list to build teams
- def player_pick(tlist, plist):
- #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
- player = choice(plist)
- i.append(player)
- plist.remove(player)
- #continue adding players until the appropriate t_size is reached
- if len(i) % t_size > 0:
- player = choice(plist)
- i.append(player)
- plist.remove(player)
- #put any leftover players on a random team
- team = choice(tlist)
- player = choice(plist)
- team.append(player)
- plist.remove(player)
- #run player picking function and print teams
- player_pick(teams, players)
- print players
- print teams
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement